home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 1999 #5 / 1999 CD 5 (black).iso / Delphi3 / install / data.z / SHLOBJ.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-08-04  |  79.4 KB  |  1,906 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Runtime Library                          }
  5. {       Windows 32bit API Interface Unit                }
  6. {                                                       }
  7. {       Copyright (c) 1996,97 Borland International     }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit ShlObj;
  12.  
  13. {$WEAKPACKAGEUNIT}
  14.  
  15. interface
  16.  
  17. uses Windows, ActiveX, CommCtrl, ShellAPI, RegStr, Messages;
  18.  
  19. { Object identifiers in the explorer's name space (ItemID and IDList)
  20.   All the items that the user can browse with the explorer (such as files,
  21.   directories, servers, work-groups, etc.) has an identifier which is unique
  22.   among items within the parent folder. Those identifiers are called item
  23.   IDs (SHITEMID). Since all its parent folders have their own item IDs,
  24.   any items can be uniquely identified by a list of item IDs, which is called
  25.   an ID list (ITEMIDLIST).
  26.  
  27.   ID lists are almost always allocated by the task allocator (see some
  28.   description below as well as OLE 2.0 SDK) and may be passed across
  29.   some of shell interfaces (such as IShellFolder). Each item ID in an ID list
  30.   is only meaningful to its parent folder (which has generated it), and all
  31.   the clients must treat it as an opaque binary data except the first two
  32.   bytes, which indicates the size of the item ID.
  33.  
  34.   When a shell extension -- which implements the IShellFolder interace --
  35.   generates an item ID, it may put any information in it, not only the data
  36.   with that it needs to identifies the item, but also some additional
  37.   information, which would help implementing some other functions efficiently.
  38.   For example, the shell's IShellFolder implementation of file system items
  39.   stores the primary (long) name of a file or a directory as the item
  40.   identifier, but it also stores its alternative (short) name, size and date
  41.   etc.
  42.  
  43.   When an ID list is passed to one of shell APIs (such as SHGetPathFromIDList),
  44.   it is always an absolute path -- relative from the root of the name space,
  45.   which is the desktop folder. When an ID list is passed to one of IShellFolder
  46.   member function, it is always a relative path from the folder (unless it
  47.   is explicitly specified). }
  48.  
  49. const
  50. // Class IDs        xx=00-9F
  51.   CLSID_ShellDesktop: TGUID = (
  52.     D1:$00021400; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  53.   CLSID_ShellLink: TGUID = (
  54.     D1:$00021401; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  55.  
  56. // Format IDs       xx=A0-CF
  57.   FMTID_Intshcut: TGUID = (
  58.     D1:$000214A0; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  59.   FMTID_InternetSite: TGUID = (
  60.     D1:$000214A1; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  61.  
  62. // command group ids xx=D0-DF
  63.   CGID_Explorer: TGUID = (
  64.     D1:$000214D0; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  65.   CGID_ShellDocView: TGUID = (
  66.     D1:$000214D1; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  67.  
  68. // Interface IDs    xx=E0-FF
  69.   IID_INewShortcutHookA: TGUID = (
  70.     D1:$000214E1; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  71.   IID_IShellBrowser: TGUID = (
  72.     D1:$000214E2; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  73.   IID_IShellView: TGUID = (
  74.     D1:$000214E3; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  75.   IID_IContextMenu: TGUID = (
  76.     D1:$000214E4; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  77.   IID_IShellIcon: TGUID = (
  78.     D1:$000214E5; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  79.   IID_IShellFolder: TGUID = (
  80.     D1:$000214E6; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  81.   IID_IShellExtInit: TGUID = (
  82.     D1:$000214E8; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  83.   IID_IShellPropSheetExt: TGUID = (
  84.     D1:$000214E9; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  85.   IID_IPersistFolder: TGUID = (
  86.     D1:$000214EA; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  87.   IID_IExtractIconA: TGUID = (
  88.     D1:$000214EB; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  89.   IID_IShellLinkA: TGUID = (
  90.     D1:$000214EE; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  91.   IID_IShellCopyHookA: TGUID = (
  92.     D1:$000214EF; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  93.   IID_IFileViewerA: TGUID = (
  94.     D1:$000214F0; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  95.   IID_ICommDlgBrowser: TGUID = (
  96.     D1:$000214F1; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  97.   IID_IEnumIDList: TGUID = (
  98.     D1:$000214F2; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  99.   IID_IFileViewerSite: TGUID = (
  100.     D1:$000214F3; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  101.   IID_IContextMenu2: TGUID = (
  102.     D1:$000214F4; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  103.   IID_IShellExecuteHook: TGUID = (
  104.     D1:$000214F5; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  105.   IID_IPropSheetPage: TGUID = (
  106.     D1:$000214F6; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  107.   IID_INewShortcutHookW: TGUID = (
  108.     D1:$000214F7; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  109.   IID_IFileViewerW: TGUID = (
  110.     D1:$000214F8; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  111.   IID_IShellLinkW: TGUID = (
  112.     D1:$000214F9; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  113.   IID_IExtractIconW: TGUID = (
  114.     D1:$000214FA; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  115.   IID_IShellExecuteHookW: TGUID = (
  116.     D1:$000214FB; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  117.   IID_IShellCopyHookW: TGUID = (
  118.     D1:$000214FC; D2:$0000; D3:$0000; D4:($C0,$00,$00,$00,$00,$00,$00,$46));
  119.   IID_IShellView2: TGUID = (
  120.     D1:$88E39E80; D2:$3578; D3:$11CF; D4:($AE,$69,$08,$00,$2B,$2E,$12,$62));
  121.  
  122. // String constants for Interface IDs
  123.   SID_INewShortcutHookA  = '{000214E1-0000-0000-C000-000000000046}';
  124.   SID_IShellBrowser      = '{000214E2-0000-0000-C000-000000000046}';
  125.   SID_IShellView         = '{000214E3-0000-0000-C000-000000000046}';
  126.   SID_IContextMenu       = '{000214E4-0000-0000-C000-000000000046}';
  127.   SID_IShellIcon         = '{000214E5-0000-0000-C000-000000000046}';
  128.   SID_IShellFolder       = '{000214E6-0000-0000-C000-000000000046}';
  129.   SID_IShellExtInit      = '{000214E8-0000-0000-C000-000000000046}';
  130.   SID_IShellPropSheetExt = '{000214E9-0000-0000-C000-000000000046}';
  131.   SID_IPersistFolder     = '{000214EA-0000-0000-C000-000000000046}';
  132.   SID_IExtractIconA      = '{000214EB-0000-0000-C000-000000000046}';
  133.   SID_IShellLinkA        = '{000214EE-0000-0000-C000-000000000046}';
  134.   SID_IShellCopyHookA    = '{000214EF-0000-0000-C000-000000000046}';
  135.   SID_IFileViewerA       = '{000214F0-0000-0000-C000-000000000046}';
  136.   SID_ICommDlgBrowser    = '{000214F1-0000-0000-C000-000000000046}';
  137.   SID_IEnumIDList        = '{000214F2-0000-0000-C000-000000000046}';
  138.   SID_IFileViewerSite    = '{000214F3-0000-0000-C000-000000000046}';
  139.   SID_IContextMenu2      = '{000214F4-0000-0000-C000-000000000046}';
  140.   SID_IShellExecuteHookA = '{000214F5-0000-0000-C000-000000000046}';
  141.   SID_IPropSheetPage     = '{000214F6-0000-0000-C000-000000000046}';
  142.   SID_INewShortcutHookW  = '{000214F7-0000-0000-C000-000000000046}';
  143.   SID_IFileViewerW       = '{000214F8-0000-0000-C000-000000000046}';
  144.   SID_IShellLinkW        = '{000214F9-0000-0000-C000-000000000046}';
  145.   SID_IExtractIconW      = '{000214FA-0000-0000-C000-000000000046}';
  146.   SID_IShellExecuteHookW = '{000214FB-0000-0000-C000-000000000046}';
  147.   SID_IShellCopyHookW    = '{000214FC-0000-0000-C000-000000000046}';
  148.   SID_IShellView2        = '{88E39E80-3578-11CF-AE69-08002B2E1262}';
  149.   
  150. type
  151. { TSHItemID -- Item ID }
  152.  
  153.   PSHItemID = ^TSHItemID;
  154.   TSHItemID = packed record           { mkid }
  155.     cb: Word;                         { Size of the ID (including cb itself) }
  156.     abID: array[0..0] of Byte;        { The item ID (variable length) }
  157.   end;
  158.  
  159. { TItemIDList -- List if item IDs (combined with 0-terminator) }
  160.  
  161.   PItemIDList = ^TItemIDList;
  162.   TItemIDList = packed record         { idl }
  163.      mkid: TSHItemID;
  164.    end;
  165.  
  166. { Task allocator API }
  167.  
  168. { All the shell extensions MUST use the task allocator (see OLE 2.0
  169.  programming guild for its definition) when they allocate or free
  170.  memory objects (mostly ITEMIDLIST) that are returned across any
  171.  shell interfaces. There are two ways to access the task allocator
  172.  from a shell extension depending on whether or not it is linked with
  173.  OLE32.DLL or not (virtual; stdcall; abstractly for efficiency).
  174.  
  175.  (1) A shell extension which calls any OLE API (i.e., linked with
  176.   OLE32.DLL) should call OLE's task allocator (by retrieving
  177.   the task allocator by calling CoGetMalloc API).
  178.  
  179.  (2) A shell extension which does not call any OLE API (i.e., not linked
  180.   with OLE32.DLL) should call the shell task allocator API (defined
  181.   below), so that the shell can quickly loads it when OLE32.DLL is not
  182.   loaded by any application at that point. }
  183.  
  184. { !!! Notes:
  185.   In next version of Windowso release, SHGetMalloc will be replaced by
  186.  the following macro.
  187.  
  188.  #define SHGetMalloc(ppmem)     CoGetMalloc(MEMCTX_TASK, ppmem) }
  189.  
  190. function SHGetMalloc(var ppMalloc: IMalloc): HResult; stdcall;
  191.  
  192. { IContextMenu interface }
  193.  
  194. { [OverView] }
  195.  
  196. { The shell uses the IContextMenu interface in following three cases.
  197.  
  198.  case-1: The shell is loading context menu extensions.
  199.    When the user clicks the right mouse button on an item within the shell's
  200.   name space (i.g., file, directory, server, work-group, etc.), it creates
  201.   the default context menu for its type, then loads context menu extensions
  202.   that are registered for that type (and its base type) so that they can
  203.   add extra menu items. Those context menu extensions are registered at
  204.   HKCR\beginProgIDend\shellex\ContextMenuHandlers.
  205.  
  206.  case-2: The shell is retrieving a context menu of sub-folders in extended
  207.    name-space.
  208.    When the explorer's name space is extended by name space extensions,
  209.   the shell calls their IShellFolder::GetUIObjectOf to get the IContextMenu
  210.   objects when it creates context menus for folders under those extended
  211.   name spaces.
  212.  
  213.  case-3: The shell is loading non-default drag and drop handler for directories.
  214.    When the user performed a non-default drag and drop onto one of file
  215.   system folders (i.e., directories), it loads shell extensions that are
  216.   registered at HKCR\beginProgIDend\DragDropHandlers. }
  217.  
  218. { [Member functions] }
  219.  
  220. { IContextMenu::QueryContextMenu }
  221.  
  222. { This member function may insert one or more menuitems to the specified 
  223.   menu (hmenu) at the specified location (indexMenu which is never be -1).
  224.   The IDs of those menuitem must be in the specified range (idCmdFirst and 
  225.   idCmdLast). It returns the maximum menuitem ID offset (ushort) in the 
  226.   'code' field (low word) of the scode. 
  227.  
  228.   The uFlags specify the context. It may have one or more of following 
  229.   flags. 
  230.  
  231.   CMF_DEFAULTONLY: This flag is passed if the user is invoking the default 
  232.   action (typically by double-clicking, case 1 and 2 only). Context menu 
  233.   extensions (case 1) should not add any menu items, and returns NOERROR. 
  234.  
  235.   CMF_VERBSONLY: The explorer passes this flag if it is constructing 
  236.   a context menu for a short-cut object (case 1 and case 2 only). If this 
  237.   flag is passed, it should not add any menu-items that is not appropriate 
  238.   from a short-cut. 
  239.   A good example is the 'Delete' menuitem, which confuses the user 
  240.   because it is not clear whether it deletes the link source item or the 
  241.   link itself. 
  242.  
  243.   CMF_EXPLORER: The explorer passes this flag if it has the left-side pane 
  244.    (case 1 and 2 only). Context menu extensions should ignore this flag. 
  245.  
  246.   High word (16-bit) are reserved for context specific communications 
  247.   and the rest of flags (13-bit) are reserved by the system. }
  248.  
  249.  
  250. { IContextMenu::InvokeCommand }
  251.  
  252. { This member is called when the user has selected one of menuitems that 
  253.   are inserted by previous QueryContextMenu member. In this case, the 
  254.   LOWORD(lpici->lpVerb) contains the menuitem ID offset (menuitem ID - 
  255.   idCmdFirst). 
  256.  
  257.    This member function may also be called programmatically. In such a case, 
  258.   lpici->lpVerb specifies the canonical name of the command to be invoked, 
  259.   which is typically retrieved by GetCommandString member previously. 
  260.  
  261.   Parameters in lpci: 
  262.     cbSize -- Specifies the size of this structure (sizeof(*lpci)) 
  263.     hwnd   -- Specifies the owner window for any message/dialog box. 
  264.     fMask  -- Specifies whether or not dwHotkey/hIcon paramter is valid. 
  265.     lpVerb -- Specifies the command to be invoked. 
  266.     lpParameters -- Parameters (optional) 
  267.     lpDirectory  -- Working directory (optional) 
  268.     nShow -- Specifies the flag to be passed to ShowWindow (SW_*). 
  269.     dwHotKey -- Hot key to be assigned to the app after invoked (optional). 
  270.     hIcon -- Specifies the icon (optional). }
  271.  
  272.  
  273. { IContextMenu::GetCommandString }
  274.  
  275. { This member function is called by the explorer either to get the 
  276.   canonical (language independent) command name (uFlags == GCS_VERB) or 
  277.   the help text ((uFlags & GCS_HELPTEXT) != 0) for the specified command. 
  278.   The retrieved canonical string may be passed to its InvokeCommand 
  279.   member function to invoke a command programmatically. The explorer 
  280.   displays the help texts in its status bar; therefore, the length of 
  281.   the help text should be reasonably short (<40 characters). 
  282.  
  283.   Parameters: 
  284.    idCmd -- Specifies menuitem ID offset (from idCmdFirst) 
  285.    uFlags -- Either GCS_VERB or GCS_HELPTEXT 
  286.    pwReserved -- Reserved (must pass NULL when calling, must ignore when called) 
  287.    pszName -- Specifies the string buffer. 
  288.    cchMax -- Specifies the size of the string buffer. }
  289.  
  290.  
  291. const
  292. { QueryContextMenu uFlags }
  293.  
  294.   CMF_NORMAL             = $00000000;
  295.   CMF_DEFAULTONLY        = $00000001;
  296.   CMF_VERBSONLY          = $00000002;
  297.   CMF_EXPLORE            = $00000004;
  298.   CMF_NOVERBS            = $00000008; 
  299.   CMF_CANRENAME          = $00000010; 
  300.   CMF_NODEFAULT          = $00000020; 
  301.   CMF_INCLUDESTATIC      = $00000040; 
  302.   CMF_RESERVED           = $FFFF0000;      { View specific }
  303.  
  304. { GetCommandString uFlags }
  305.  
  306.   GCS_VERBA            = $00000000;     { canonical verb }
  307.   GCS_HELPTEXTA        = $00000001;     { help text (for status bar) }
  308.   GCS_VALIDATEA        = $00000002;     { validate command exists }
  309.   GCS_VERBW            = $00000004;     { canonical verb (unicode) }
  310.   GCS_HELPTEXTW        = $00000005;     { help text (unicode version) }
  311.   GCS_VALIDATEW        = $00000006;     { validate command exists (unicode) }
  312.   GCS_UNICODE          = $00000004;     { for bit testing - Unicode string }
  313.  
  314.   GCS_VERB            = GCS_VERBA; 
  315.   GCS_HELPTEXT        = GCS_HELPTEXTA; 
  316.   GCS_VALIDATE        = GCS_VALIDATEA; 
  317.  
  318.   CMDSTR_NEWFOLDERA       = 'NewFolder';
  319.   CMDSTR_VIEWLISTA        = 'ViewList'; 
  320.   CMDSTR_VIEWDETAILSA     = 'ViewDetails'; 
  321.   CMDSTR_NEWFOLDERW       = 'NewFolder'; // !!! make WideString() ?
  322.   CMDSTR_VIEWLISTW        = 'ViewList'; 
  323.   CMDSTR_VIEWDETAILSW     = 'ViewDetails';
  324.  
  325.   CMDSTR_NEWFOLDER        = CMDSTR_NEWFOLDERA; 
  326.   CMDSTR_VIEWLIST         = CMDSTR_VIEWLISTA; 
  327.   CMDSTR_VIEWDETAILS      = CMDSTR_VIEWDETAILSA; 
  328.  
  329.   CMIC_MASK_HOTKEY            = SEE_MASK_HOTKEY;
  330.   CMIC_MASK_ICON              = SEE_MASK_ICON;
  331.   CMIC_MASK_FLAG_NO_UI        = SEE_MASK_FLAG_NO_UI; 
  332.   CMIC_MASK_UNICODE           = SEE_MASK_UNICODE; 
  333.   CMIC_MASK_NO_CONSOLE        = SEE_MASK_NO_CONSOLE; 
  334. //  CMIC_MASK_HASLINKNAME       = SEE_MASK_HASLINKNAME; - not defined in shellapi
  335. //  CMIC_MASK_FLAG_SEP_VDM      = SEE_MASK_FLAG_SEPVDM; - not defined in shellapi
  336. //  CMIC_MASK_HASTITLE          = SEE_MASK_HASTITLE; - not defined in shellapi
  337.   CMIC_MASK_ASYNCOK           = SEE_MASK_ASYNCOK; 
  338.  
  339. type
  340.   PCMInvokeCommandInfo = ^TCMInvokeCommandInfo;
  341.   TCMInvokeCommandInfo = packed record
  342.     cbSize: DWORD;        { must be sizeof(CMINVOKECOMMANDINFO) }
  343.     fMask: DWORD;         { any combination of CMIC_MASK_* }
  344.     hwnd: HWND;           { might be NULL (indicating no owner window) }
  345.     lpVerb: LPCSTR;       { either a string of MAKEINTRESOURCE(idOffset) }
  346.     lpParameters: LPCSTR; { might be NULL (indicating no parameter) }
  347.     lpDirectory: LPCSTR;  { might be NULL (indicating no specific directory) }
  348.     nShow: Integer;       { one of SW_ values for ShowWindow() API }
  349.     dwHotKey: DWORD;
  350.     hIcon: THandle;
  351.   end;
  352.  
  353.   PCMInvokeCommandInfoEx = ^TCMInvokeCommandInfoEx;
  354.   TCMInvokeCommandInfoEx = packed record
  355.     cbSize: DWORD;       { must be sizeof(CMINVOKECOMMANDINFOEX) }
  356.     fMask: DWORD;        { any combination of CMIC_MASK_* }
  357.     hwnd: HWND;          { might be NULL (indicating no owner window) }
  358.     lpVerb: LPCSTR;      { either a string or MAKEINTRESOURCE(idOffset) }
  359.     lpParameters: LPCSTR;{ might be NULL (indicating no parameter) }
  360.     lpDirectory: LPCSTR; { might be NULL (indicating no specific directory) }
  361.     nShow: Integer;       { one of SW_ values for ShowWindow() API }
  362.     dwHotKey: DWORD;
  363.     hIcon: THandle;
  364.     lpTitle: LPCSTR;     { For CreateProcess-StartupInfo.lpTitle }
  365.     lpVerbW: LPCWSTR;       { Unicode verb (for those who can use it) }
  366.     lpParametersW: LPCWSTR; { Unicode parameters (for those who can use it) }
  367.     lpDirectoryW: LPCWSTR;  { Unicode directory (for those who can use it) }
  368.     lpTitleW: LPCWSTR;      { Unicode title (for those who can use it) }
  369.   end;
  370.   
  371.   IContextMenu = interface(IUnknown)
  372.     [SID_IContextMenu]
  373.     function QueryContextMenu(Menu: HMENU; 
  374.       indexMenu, idCmdFirst, idCmdLast, uFlags: UINT): HResult; stdcall;
  375.     function InvokeCommand(var lpici: TCMInvokeCommandInfo): HResult; stdcall;
  376.     function GetCommandString(idCmd, uType: UINT; pwReserved: PUINT;
  377.       pszName: LPSTR; cchMax: UINT): HResult; stdcall;
  378.   end;
  379.  
  380. { IContextMenu2 (IContextMenu with one new member) }
  381. { IContextMenu2.HandleMenuMsg }
  382.  
  383. {  This function is called, if the client of IContextMenu is aware of }
  384. { IContextMenu2 interface and receives one of following messages while }
  385. { it is calling TrackPopupMenu (in the window proc of hwndOwner): }
  386. {      WM_INITPOPUP, WM_DRAWITEM and WM_MEASUREITEM }
  387. {  The callee may handle these messages to draw owner draw menuitems. }
  388.  
  389.   IContextMenu2 = interface(IContextMenu)
  390.     [SID_IContextMenu2]
  391.     function HandleMenuMsg(uMsg: UINT): HResult; stdcall;
  392.   end;
  393.       
  394. { Interface: IShellExtInit }
  395.  
  396. { The IShellExtInit interface is used by the explorer to initialize shell 
  397.   extension objects. The explorer (1) calls CoCreateInstance (or equivalent) 
  398.   with the registered CLSID and IID_IShellExtInit, (2) calls its Initialize 
  399.   member, then (3) calls its QueryInterface to a particular interface (such 
  400.   as IContextMenu or IPropSheetExt and (4) performs the rest of operation. }
  401.  
  402. { [Member functions] }
  403.  
  404. { IShellExtInit.Initialize }
  405.  
  406. { This member function is called when the explorer is initializing either
  407.   context menu extension, property sheet extension or non-default drag-drop
  408.   extension.
  409.  
  410.   Parameters: (context menu or property sheet extension) 
  411.    pidlFolder -- Specifies the parent folder 
  412.    lpdobj -- Spefifies the set of items selected in that folder. 
  413.    hkeyProgID -- Specifies the type of the focused item in the selection. 
  414.  
  415.   Parameters: (non-default drag-and-drop extension) 
  416.    pidlFolder -- Specifies the target (destination) folder 
  417.    lpdobj -- Specifies the items that are dropped (see the description 
  418.     about shell's clipboard below for clipboard formats). 
  419.    hkeyProgID -- Specifies the folder type. }
  420.  
  421. type
  422.   IShellExtInit = interface(IUnknown)
  423.     [SID_IShellExtInit]
  424.     function Initialize(pidlFolder: PItemIDList; lpdobj: IDataObject;
  425.       hKeyProgID: HKEY): HResult; stdcall;
  426.   end;
  427.  
  428. {=========================================================================== }
  429.  
  430. { Interface: IShellPropSheetExt }
  431.  
  432. { The explorer uses the IShellPropSheetExt to allow property sheet
  433.   extensions or control panel extensions to add additional property
  434.   sheet pages. }
  435.  
  436. { [Member functions] }
  437.  
  438. { IShellPropSheetExt.AddPages }
  439.  
  440. { The explorer calls this member function when it finds a registered 
  441.   property sheet extension for a particular type of object. For each 
  442.   additional page, the extension creates a page object by calling 
  443.   CreatePropertySheetPage API and calls lpfnAddPage. 
  444.  
  445.    Parameters: 
  446.     lpfnAddPage -- Specifies the callback function. 
  447.     lParam -- Specifies the opaque handle to be passed to the callback function. }
  448.  
  449.  
  450. { IShellPropSheetExt.ReplacePage }
  451.  
  452. { The explorer never calls this member of property sheet extensions. The 
  453.   explorer calls this member of control panel extensions, so that they 
  454.   can replace some of default control panel pages (such as a page of 
  455.   mouse control panel). 
  456.  
  457.    Parameters: 
  458.     uPageID -- Specifies the page to be replaced. 
  459.     lpfnReplace Specifies the callback function. 
  460.     lParam -- Specifies the opaque handle to be passed to the callback function. }
  461.  
  462. type
  463.   IShellPropSheetExt = interface(IUnknown)
  464.     [SID_IShellPropSheetExt]
  465.     function AddPages(lpfnAddPage: TFNAddPropSheetPage; lParam: LPARAM): HResult; stdcall;
  466.     function ReplacePage(uPageID: UINT; lpfnReplaceWith: TFNAddPropSheetPage;
  467.       lParam: LPARAM): HResult; stdcall;
  468.   end;
  469.  
  470. { IPersistFolder Interface }
  471. {  The IPersistFolder interface is used by the file system implementation of }
  472. { IShellFolder::BindToObject when it is initializing a shell folder object. }
  473.  
  474. { IPersistFolder::Initialize }
  475. {  This member function is called when the explorer is initializing a }
  476. { shell folder object. }
  477. {  Parameters: }
  478. {   pidl -- Specifies the absolute location of the folder. }
  479.  
  480.   IPersistFolder = interface(IPersist)
  481.     [SID_IPersistFolder]
  482.     function Initialize(pidl: PItemIDList): HResult; stdcall;
  483.   end;
  484.  
  485. { IExtractIcon interface }
  486.  
  487. { This interface is used in two different places in the shell.
  488.  
  489.   Case-1: Icons of sub-folders for the scope-pane of the explorer.
  490.  
  491.    It is used by the explorer to get the 'icon location' of
  492.   sub-folders from each shell folders. When the user expands a folder
  493.   in the scope pane of the explorer, the explorer does following:
  494.    (1) binds to the folder (gets IShellFolder),
  495.    (2) enumerates its sub-folders by calling its EnumObjects member,
  496.    (3) calls its GetUIObjectOf member to get IExtractIcon interface
  497.       for each sub-folders.
  498.    In this case, the explorer uses only IExtractIcon.GetIconLocation
  499.   member to get the location of the appropriate icon. An icon location
  500.   always consists of a file name (typically DLL or EXE) and either an icon
  501.   resource or an icon index.
  502.  
  503.  
  504.   Case-2: Extracting an icon image from a file
  505.  
  506.    It is used by the shell when it extracts an icon image
  507.   from a file. When the shell is extracting an icon from a file,
  508.   it does following:
  509.    (1) creates the icon extraction handler object (by getting its CLSID
  510.       under the beginProgIDend\shell\ExtractIconHanler key and calling
  511.       CoCreateInstance requesting for IExtractIcon interface).
  512.    (2) Calls IExtractIcon.GetIconLocation.
  513.    (3) Then, calls IExtractIcon.Extract with the location/index pair.
  514.    (4) If (3) returns NOERROR, it uses the returned icon.
  515.    (5) Otherwise, it recursively calls this logic with new location
  516.       assuming that the location string contains a fully qualified path name.
  517.  
  518.    From extension programmer's point of view, there are only two cases
  519.   where they provide implementations of IExtractIcon:
  520.    Case-1) providing explorer extensions (i.e., IShellFolder).
  521.    Case-2) providing per-instance icons for some types of files.
  522.  
  523.   Because Case-1 is described above, we'll explain only Case-2 here.
  524.  
  525.   When the shell is about display an icon for a file, it does following:
  526.    (1) Finds its ProgID and ClassID.
  527.    (2) If the file has a ClassID, it gets the icon location string from the
  528.      'DefaultIcon' key under it. The string indicates either per-class
  529.      icon (e.g., 'FOOBAR.DLL,2') or per-instance icon (e.g., '%1,1').
  530.    (3) If a per-instance icon is specified, the shell creates an icon
  531.      extraction handler object for it, and extracts the icon from it
  532.      (which is described above).
  533.  
  534.    It is important to note that the shell calls IExtractIcon.GetIconLocation
  535.   first, then calls IExtractIcon.Extract. Most application programs
  536.   that support per-instance icons will probably store an icon location
  537.   (DLL/EXE name and index/id) rather than an icon image in each file.
  538.   In those cases, a programmer needs to implement only the GetIconLocation
  539.   member and it Extract member simply returns S_FALSE. They need to
  540.   implement Extract member only if they decided to store the icon images
  541.   within files themselved or some other database (which is very rare). }
  542.  
  543. { [Member functions] }
  544.  
  545. { IExtractIcon.GetIconLocation }
  546.  
  547. { This function returns an icon location.
  548.  
  549.   Parameters:
  550.    uFlags     [in]  -- Specifies if it is opened or not (GIL_OPENICON or 0)
  551.    szIconFile [out] -- Specifies the string buffer buffer for a location name.
  552.    cchMax     [in]  -- Specifies the size of szIconFile (almost always MAX_PATH)
  553.    piIndex    [out] -- Sepcifies the address of UINT for the index.
  554.    pwFlags    [out] -- Returns GIL_* flags
  555.   Returns:
  556.    NOERROR, if it returns a valid location; S_FALSE, if the shell use a
  557.    default icon.
  558.  
  559.   Notes: The location may or may not be a path to a file. The caller can
  560.    not assume anything unless the subsequent Extract member call returns
  561.    S_FALSE.
  562.  
  563.    if the returned location is not a path to a file, GIL_NOTFILENAME should
  564.    be set in the returned flags. }
  565.  
  566. { IExtractIcon.Extract }
  567.  
  568. { This function extracts an icon image from a specified file.
  569.  
  570.   Parameters:
  571.    pszFile [in] -- Specifies the icon location (typically a path to a file).
  572.    nIconIndex [in] -- Specifies the icon index.
  573.    phiconLarge [out] -- Specifies the HICON variable for large icon.
  574.    phiconSmall [out] -- Specifies the HICON variable for small icon.
  575.    nIconSize [in] -- Specifies the size icon required (size of large icon)
  576.              LOWORD is the requested large icon size
  577.              HIWORD is the requested small icon size
  578.   Returns:
  579.    NOERROR, if it extracted the from the file.
  580.    S_FALSE, if the caller should extract from the file specified in the
  581.        location. }
  582.  
  583. const
  584.   GIL_OPENICON         = $0001;      { allows containers to specify an "open" look }
  585.   GIL_FORSHELL         = $0002;      { icon is to be displayed in a ShellFolder }
  586.   GIL_ASYNC            = $0020;      { this is an async extract, return E_ASYNC }
  587.  
  588. { GetIconLocation() return flags }
  589.  
  590.   GIL_SIMULATEDOC      = $0001;      { simulate this document icon for this }
  591.   GIL_PERINSTANCE      = $0002;      { icons from this class are per instance (each file has its own) }
  592.   GIL_PERCLASS         = $0004;      { icons from this class per class (shared for all files of this type) }
  593.   GIL_NOTFILENAME      = $0008;      { location is not a filename, must call ::ExtractIcon }
  594.   GIL_DONTCACHE        = $0010;      { this icon should not be cached }
  595.  
  596. type
  597.   IExtractIconA = interface(IUnknown)
  598.     [SID_IExtractIconA]
  599.     function GetIconLocation(uFlags: UINT; szIconFile: PAnsiChar; cchMax: UINT;
  600.       out piIndex: Integer; out pwFlags: UINT): HResult; stdcall;
  601.     function Extract(pszFile: PAnsiChar; nIconIndex: UINT;
  602.       out phiconLarge, phiconSmall: HICON; nIconSize: UINT): HResult; stdcall;
  603.   end;
  604.   IExtractIconW = interface(IUnknown)
  605.     [SID_IExtractIconW]
  606.     function GetIconLocation(uFlags: UINT; szIconFile: PWideChar; cchMax: UINT;
  607.       out piIndex: Integer; out pwFlags: UINT): HResult; stdcall;
  608.     function Extract(pszFile: PWideChar; nIconIndex: UINT;
  609.       out phiconLarge, phiconSmall: HICON; nIconSize: UINT): HResult; stdcall;
  610.   end;
  611.   IExtractIcon = IExtractIconA;
  612.  
  613.  
  614. { IShellIcon Interface }
  615. { used to get a icon index for a IShellFolder object. }
  616.  
  617. { this interface can be implemented by a IShellFolder, as a quick way to }
  618. { return the icon for a object in the folder. }
  619.  
  620. { a instance of this interface is only created once for the folder, unlike }
  621. { IExtractIcon witch is created once for each object. }
  622.  
  623. { if a ShellFolder does not implement this interface, the standard }
  624. { GetUIObject(....IExtractIcon) method will be used to get a icon }
  625. { for all objects. }
  626.  
  627. { the following standard imagelist indexs can be returned: }
  628.  
  629. {      0   document (blank page) (not associated) }
  630. {      1   document (with stuff on the page) }
  631. {      2   application (exe, com, bat) }
  632. {      3   folder (plain) }
  633. {      4   folder (open) }
  634.  
  635. { IShellIcon.GetIconOf(pidl, flags, lpIconIndex) }
  636.  
  637. {      pidl            object to get icon for. }
  638. {      flags           GIL_* input flags (GIL_OPEN, ...) }
  639. {      lpIconIndex     place to return icon index. }
  640.  
  641. {  returns: }
  642. {      NOERROR, if lpIconIndex contains the correct system imagelist index. }
  643. {      S_FALSE, if unable to get icon for this object, go through }
  644. {               GetUIObject, IExtractIcon, methods. }
  645.  
  646.   IShellIcon = interface(IUnknown)
  647.     [SID_IShellIcon]
  648.     function GetIconOf(pidl: PItemIDList; flags: UINT; 
  649.       out IconIndex: Integer): HResult; stdcall;
  650.   end;
  651.  
  652.   
  653. { IShellLink Interface }
  654. const
  655. { IShellLink.Resolve fFlags }
  656.  
  657.   SLR_NO_UI           = $0001;
  658.   SLR_ANY_MATCH       = $0002;
  659.   SLR_UPDATE          = $0004;
  660.  
  661. { IShellLink.GetPath fFlags }
  662.  
  663.   SLGP_SHORTPATH      = $0001;
  664.   SLGP_UNCPRIORITY    = $0002;
  665.  
  666. type
  667.   IShellLinkA = interface(IUnknown) { sl }
  668.     [SID_IShellLinkA]
  669.     function GetPath(pszFile: PAnsiChar; cchMaxPath: Integer;
  670.       var pfd: TWin32FindData; fFlags: DWORD): HResult; stdcall;
  671.     function GetIDList(var ppidl: PItemIDList): HResult; stdcall;
  672.     function SetIDList(pidl: PItemIDList): HResult; stdcall;
  673.     function GetDescription(pszName: PAnsiChar; cchMaxName: Integer): HResult; stdcall;
  674.     function SetDescription(pszName: PAnsiChar): HResult; stdcall;
  675.     function GetWorkingDirectory(pszDir: PAnsiChar; cchMaxPath: Integer): HResult; stdcall;
  676.     function SetWorkingDirectory(pszDir: PAnsiChar): HResult; stdcall;
  677.     function GetArguments(pszArgs: PAnsiChar; cchMaxPath: Integer): HResult; stdcall;
  678.     function SetArguments(pszArgs: PAnsiChar): HResult; stdcall;
  679.     function GetHotkey(var pwHotkey: Word): HResult; stdcall;
  680.     function SetHotkey(wHotkey: Word): HResult; stdcall;
  681.     function GetShowCmd(out piShowCmd: Integer): HResult; stdcall;
  682.     function SetShowCmd(iShowCmd: Integer): HResult; stdcall;
  683.     function GetIconLocation(pszIconPath: PAnsiChar; cchIconPath: Integer;
  684.       out piIcon: Integer): HResult; stdcall;
  685.     function SetIconLocation(pszIconPath: PAnsiChar; iIcon: Integer): HResult; stdcall;
  686.     function SetRelativePath(pszPathRel: PAnsiChar; dwReserved: DWORD): HResult; stdcall;
  687.     function Resolve(Wnd: HWND; fFlags: DWORD): HResult; stdcall;
  688.     function SetPath(pszFile: PAnsiChar): HResult; stdcall;
  689.   end;
  690.   IShellLinkW = interface(IUnknown) { sl }
  691.     [SID_IShellLinkW]
  692.     function GetPath(pszFile: PWideChar; cchMaxPath: Integer;
  693.       var pfd: TWin32FindData; fFlags: DWORD): HResult; stdcall;
  694.     function GetIDList(var ppidl: PItemIDList): HResult; stdcall;
  695.     function SetIDList(pidl: PItemIDList): HResult; stdcall;
  696.     function GetDescription(pszName: PWideChar; cchMaxName: Integer): HResult; stdcall;
  697.     function SetDescription(pszName: PWideChar): HResult; stdcall;
  698.     function GetWorkingDirectory(pszDir: PWideChar; cchMaxPath: Integer): HResult; stdcall;
  699.     function SetWorkingDirectory(pszDir: PWideChar): HResult; stdcall;
  700.     function GetArguments(pszArgs: PWideChar; cchMaxPath: Integer): HResult; stdcall;
  701.     function SetArguments(pszArgs: PWideChar): HResult; stdcall;
  702.     function GetHotkey(var pwHotkey: Word): HResult; stdcall;
  703.     function SetHotkey(wHotkey: Word): HResult; stdcall;
  704.     function GetShowCmd(out piShowCmd: Integer): HResult; stdcall;
  705.     function SetShowCmd(iShowCmd: Integer): HResult; stdcall;
  706.     function GetIconLocation(pszIconPath: PWideChar; cchIconPath: Integer;
  707.       out piIcon: Integer): HResult; stdcall;
  708.     function SetIconLocation(pszIconPath: PWideChar; iIcon: Integer): HResult; stdcall;
  709.     function SetRelativePath(pszPathRel: PWideChar; dwReserved: DWORD): HResult; stdcall;
  710.     function Resolve(Wnd: HWND; fFlags: DWORD): HResult; stdcall;
  711.     function SetPath(pszFile: PWideChar): HResult; stdcall;
  712.   end;
  713.   IShellLink = IShellLinkA;
  714.  
  715. { IShellExecuteHook Interface }
  716.  
  717.   IShellExecuteHookA = interface(IUnknown) { sl }
  718.     [SID_IShellExecuteHookA]
  719.     function Execute(var ShellExecuteInfo: TShellExecuteInfo): HResult; stdcall;
  720.   end;
  721.   IShellExecuteHookW = interface(IUnknown) { sl }
  722.     [SID_IShellExecuteHookW]
  723.     function Execute(var ShellExecuteInfo: TShellExecuteInfo): HResult; stdcall;
  724.   end;
  725.   IShellExecuteHook = IShellExecuteHookA;
  726.  
  727. { INewShortcutHook Interface }
  728.  
  729.   INewShortcutHookA = interface(IUnknown) { sl }
  730.     [SID_INewShortcutHookA]
  731.     function SetReferent(pcszReferent: PAnsiChar; Wnd: HWND): HResult; stdcall;
  732.     function GetReferent(pcszReferent: PAnsiChar; cchReferent: Integer): HResult; stdcall;
  733.     function SetFolder(pcszFolder: PAnsiChar; Wnd: HWND): HResult; stdcall;
  734.     function GetFolder(pcszFolder: PAnsiChar; cchFolder: Integer): HResult; stdcall;
  735.     function GetName(pcszName: PAnsiChar; cchName: Integer): HResult; stdcall;
  736.     function GetExtension(pcszExtension: PAnsiChar; cchExtension: Integer): HResult; stdcall;
  737.   end;
  738.   INewShortcutHookW = interface(IUnknown) { sl }
  739.     [SID_INewShortcutHookW]
  740.     function SetReferent(pcszReferent: PWideChar; Wnd: HWND): HResult; stdcall;
  741.     function GetReferent(pcszReferent: PWideChar; cchReferent: Integer): HResult; stdcall;
  742.     function SetFolder(pcszFolder: PWideChar; Wnd: HWND): HResult; stdcall;
  743.     function GetFolder(pcszFolder: PWideChar; cchFolder: Integer): HResult; stdcall;
  744.     function GetName(pcszName: PWideChar; cchName: Integer): HResult; stdcall;
  745.     function GetExtension(pcszExtension: PWideChar; cchExtension: Integer): HResult; stdcall;
  746.   end;
  747.   INewShortcutHook = INewShortcutHookA;
  748.  
  749. { ICopyHook Interface }
  750.  
  751. { The copy hook is called whenever file system directories are
  752.   copy/moved/deleted/renamed via the shell.  It is also called by the shell
  753.   on changes of status of printers.
  754.   Clients register their id under STRREG_SHEX_COPYHOOK for file system hooks
  755.   and STRREG_SHEx_PRNCOPYHOOK for printer hooks.
  756.   the CopyCallback is called prior to the action, so the hook has the chance
  757.   to allow, deny or cancel the operation by returning the falues:
  758.      IDYES  -  means allow the operation
  759.      IDNO   -  means disallow the operation on this file, but continue with
  760.           any other operations (eg. batch copy)
  761.      IDCANCEL - means disallow the current operation and cancel any pending
  762.           operations
  763.    arguments to the CopyCallback
  764.       hwnd - window to use for any UI
  765.       wFunc - what operation is being done
  766.       wFlags - and flags (FOF_*) set in the initial call to the file operation
  767.       pszSrcFile - name of the source file
  768.       dwSrcAttribs - file attributes of the source file
  769.       pszDestFile - name of the destiation file (for move and renames)
  770.       dwDestAttribs - file attributes of the destination file }
  771.  
  772. type
  773.   ICopyHookA = interface(IUnknown) { sl }
  774.     [SID_IShellCopyHookA]
  775.     function CopyCallback(Wnd: HWND; wFunc, wFlags: UINT; pszSrcFile: PAnsiChar; 
  776.       dwSrcAttribs: DWORD; pszDestFile: PAnsiChar; dwDestAttribs: DWORD): UINT; stdcall;
  777.   end;
  778.   ICopyHookW = interface(IUnknown) { sl }
  779.     [SID_IShellCopyHookW]
  780.     function CopyCallback(Wnd: HWND; wFunc, wFlags: UINT; pszSrcFile: PWideChar; 
  781.       dwSrcAttribs: DWORD; pszDestFile: PWideChar; dwDestAttribs: DWORD): UINT; stdcall;
  782.   end;
  783.   ICopyHook = ICopyHookA;
  784.  
  785. { IFileViewerSite Interface }
  786.  
  787. type
  788.   IFileViewerSite = interface(IUnknown)
  789.     [SID_IFileViewerSite]
  790.     function SetPinnedWindow(Wnd: HWND): HResult; stdcall;
  791.     function GetPinnedWindow(var Wnd: HWND): HResult; stdcall;
  792.   end;
  793.  
  794. { IFileViewer Interface }
  795.  
  796. { Implemented in a FileViewer component object.  Used to tell a
  797.   FileViewer to PrintTo or to view, the latter happening though
  798.   ShowInitialize and Show.  The filename is always given to the
  799.   viewer through IPersistFile. }
  800.  
  801. type
  802.   PFVShowInfo = ^TFVShowInfo;
  803.   TFVShowInfo = packed record
  804.     { Stuff passed into viewer (in) }
  805.      cbSize: DWORD;           { Size of structure for future expansion... }
  806.      hwndOwner: HWND;         { who is the owner window. }
  807.      iShow: Integer;          { The show command }
  808.      
  809.     { Passed in and updated  (in/Out) }
  810.      dwFlags: DWORD;          { flags }
  811.      rect: TRECT;             { Where to create the window may have defaults }
  812.      punkRel: IUNKNOWN;       { Relese this interface when window is visible }
  813.      
  814.     { Stuff that might be returned from viewer (out) }
  815.      strNewFile: array[0..MAX_PATH-1] of TOleChar;   { New File to view. }
  816.     end;
  817.  
  818. const
  819. { Define File View Show Info Flags. }
  820.  
  821.    FVSIF_RECT      = $00000001;      { The rect variable has valid data. }
  822.    FVSIF_PINNED    = $00000002;      { We should Initialize pinned }
  823.  
  824.    FVSIF_NEWFAILED = $08000000;      { The new file passed back failed
  825.                        to be viewed. }
  826.  
  827.    FVSIF_NEWFILE   = $80000000;      { A new file to view has been returned }
  828.    FVSIF_CANVIEWIT = $40000000;      { The viewer can view it. }
  829.  
  830. type
  831.   IFileViewerA = interface(IUnknown)
  832.     [SID_IFileViewerA]
  833.     function ShowInitialize(fsi: IFileViewerSite): HResult; stdcall;
  834.     function Show(var pvsi: TFVShowInfo): HResult; stdcall;
  835.     function PrintTo(pszDriver: PAnsiChar; fSuppressUI: BOOL): HResult; stdcall;
  836.   end;
  837.   IFileViewerW = interface(IUnknown)
  838.     [SID_IFileViewerW]
  839.     function ShowInitialize(fsi: IFileViewerSite): HResult; stdcall;
  840.     function Show(var pvsi: TFVShowInfo): HResult; stdcall;
  841.     function PrintTo(pszDriver: PWideChar; fSuppressUI: BOOL): HResult; stdcall;
  842.   end;
  843.   IFileViewer = IFileViewerA;
  844.  
  845. { CommandTarget ids. for shell doc view wedge }
  846.  
  847.   TSHDVIDEnums = ( 
  848.     SHDVID_SETPROGRESSPOS,
  849.     SHDVID_SETPROGRESSRANGE,
  850.     SHDVID_SETSTATUSTEXT,        { variantIn  bstr }
  851.     SHDVID_REFRESH,
  852.     SHDVID_STOP,
  853.     SHDVID_UPDATECOMMANDS, { / this forces a re-querystatus of the command targets. }
  854.                { / the arg in can specify a specific one to update or NIL for evrything }
  855.     SHDVID_SETTITLE,            { variantIn bstr }
  856.     SHDVID_FINALTITLEAVAIL,     { variantIn bstr - sent after final SETTITLE is sent }
  857.     SHDVID_STARTLOAD,           { NIL for everything }
  858.     SHDVID_STOPLOAD,            { NIL for everything }
  859.     SHDVID_CCALLBACK,           { callback to arbitrary C func }
  860.     SHDVID_MENUEXEC,            { do menu command }
  861.     SHDVID_MENUQS               { query menu commands }
  862.   );
  863.   
  864. { IShellBrowser/IShellView/IShellFolder interface }
  865.  
  866. {  These three interfaces are used when the shell communicates with }
  867. { name space extensions. The shell (explorer) provides IShellBrowser }
  868. { interface, and extensions implements IShellFolder and IShellView }
  869. { interfaces. }
  870.  
  871. { ========================================================================== }
  872.  
  873.  
  874. { -------------------------------------------------------------------------- }
  875.  
  876. { Command/menuitem IDs }
  877.  
  878. {  The explorer dispatches WM_COMMAND messages based on the range of }
  879. { command/menuitem IDs. All the IDs of menuitems that the view (right }
  880. { pane) inserts must be in FCIDM_SHVIEWFIRST/LAST (otherwise, the explorer }
  881. { won't dispatch them). The view should not deal with any menuitems }
  882. { in FCIDM_BROWSERFIRST/LAST (otherwise, it won't work with the future }
  883. { version of the shell). }
  884.  
  885. {  FCIDM_SHVIEWFIRST/LAST      for the right pane (IShellView) }
  886. {  FCIDM_BROWSERFIRST/LAST     for the explorer frame (IShellBrowser) }
  887. {  FCIDM_GLOBAL/LAST           for the explorer's submenu IDs }
  888.  
  889. const
  890.   FCIDM_SHVIEWFIRST               = $0000; 
  891.   FCIDM_SHVIEWLAST                = $7fff; 
  892.   FCIDM_BROWSERFIRST              = $a000; 
  893.   FCIDM_BROWSERLAST               = $bf00; 
  894.   FCIDM_GLOBALFIRST               = $8000; 
  895.   FCIDM_GLOBALLAST                = $9fff; 
  896.  
  897.  
  898. { Global submenu IDs and separator IDs }
  899.  
  900.   FCIDM_MENU_FILE                 = FCIDM_GLOBALFIRST+$0000; 
  901.   FCIDM_MENU_EDIT                 = FCIDM_GLOBALFIRST+$0040; 
  902.   FCIDM_MENU_VIEW                 = FCIDM_GLOBALFIRST+$0080; 
  903.   FCIDM_MENU_VIEW_SEP_OPTIONS     = FCIDM_GLOBALFIRST+$0081; 
  904.   FCIDM_MENU_TOOLS                = FCIDM_GLOBALFIRST+$00c0; 
  905.   FCIDM_MENU_TOOLS_SEP_GOTO       = FCIDM_GLOBALFIRST+$00c1; 
  906.   FCIDM_MENU_HELP                 = FCIDM_GLOBALFIRST+$0100; 
  907.   FCIDM_MENU_FIND                 = FCIDM_GLOBALFIRST+$0140; 
  908.   FCIDM_MENU_EXPLORE              = FCIDM_GLOBALFIRST+$0150; 
  909.   FCIDM_MENU_FAVORITES            = FCIDM_GLOBALFIRST+$0170; 
  910.  
  911. { -------------------------------------------------------------------------- }
  912. { control IDs known to the view }
  913. { -------------------------------------------------------------------------- }
  914.  
  915.   FCIDM_TOOLBAR          = FCIDM_BROWSERFIRST + 0; 
  916.   FCIDM_STATUS           = FCIDM_BROWSERFIRST + 1; 
  917.  
  918.  
  919. { -------------------------------------------------------------------------- }
  920.  
  921. { FOLDERSETTINGS }
  922.  
  923. {  FOLDERSETTINGS is a data structure that explorer passes from one folder }
  924. { view to another, when the user is browsing. It calls ISV::GetCurrentInfo }
  925. { member to get the current settings and pass it to ISV::CreateViewWindow }
  926. { to allow the next folder view "inherit" it. These settings assumes a }
  927. { particular UI (which the shell's folder view has), and shell extensions }
  928. { may or may not use those settings. }
  929.  
  930. { -------------------------------------------------------------------------- }
  931.  
  932. { NB Bitfields. }
  933. { FWF_DESKTOP implies FWF_TRANSPARENT/NOCLIENTEDGE/NOSCROLL }
  934. const
  935.     FWF_AUTOARRANGE = $0001; 
  936.     FWF_ABBREVIATEDNAMES = $0002; 
  937.     FWF_SNAPTOGRID = $0004; 
  938.     FWF_OWNERDATA = $0008; 
  939.     FWF_BESTFITWINDOW = $0010; 
  940.     FWF_DESKTOP = $0020; 
  941.     FWF_SINGLESEL = $0040; 
  942.     FWF_NOSUBFOLDERS = $0080; 
  943.     FWF_TRANSPARENT = $0100; 
  944.     FWF_NOCLIENTEDGE = $0200; 
  945.     FWF_NOSCROLL    = $0400; 
  946.     FWF_ALIGNLEFT   = $0800; 
  947.     FWF_SINGLECLICKACTIVATE = $8000; { TEMPORARY -- NO UI FOR THIS }
  948.  
  949.     FVM_ICON = 1; 
  950.     FVM_SMALLICON = 2; 
  951.     FVM_LIST = 3; 
  952.     FVM_DETAILS = 4; 
  953.  
  954. type
  955.   PFolderSettings = ^TFolderSettings;
  956.   TFolderSettings = packed record 
  957.     ViewMode: UINT;      { View mode (FOLDERVIEWMODE values) }
  958.     fFlags: UINT;        { View options (FOLDERFLAGS bits) }
  959.   end;
  960.  
  961. { -------------------------------------------------------------------------- }
  962.  
  963. { Interface:   IShellBrowser }
  964.  
  965. {  IShellBrowser interface is the interface that is provided by the shell }
  966. { explorer/folder frame window. When it creates the "contents pane" of }
  967. { a shell folder (which provides IShellFolder interface), it calls its }
  968. { CreateViewObject member function to create an IShellView object. Then, }
  969. { it calls its CreateViewWindow member to create the "contents pane" }
  970. { window. The pointer to the IShellBrowser interface is passed to }
  971. { the IShellView object as a parameter to this CreateViewWindow member }
  972. { function call. }
  973.  
  974. {    +--------------------------+  <-- Explorer window }
  975. {    | [] Explorer              | }
  976. {    |--------------------------+       IShellBrowser }
  977. {    | File Edit View ..        | }
  978. {    |--------------------------| }
  979. {    |        |                 | }
  980. {    |        |              <-------- Content pane }
  981. {    |        |                 | }
  982. {    |        |                 |       IShellView }
  983. {    |        |                 | }
  984. {    |        |                 | }
  985. {    +--------------------------+ }
  986.  
  987.  
  988.  
  989. { [Member functions] }
  990.  
  991.  
  992. { IShellBrowser.GetWindow(phwnd) }
  993.  
  994. {   Inherited from IOleWindow.GetWindow. }
  995.  
  996.  
  997. { IShellBrowser.ContextSensitiveHelp(fEnterMode) }
  998.  
  999. {   Inherited from IOleWindow.ContextSensitiveHelp. }
  1000.  
  1001.  
  1002. { IShellBrowser.InsertMenusSB(hmenuShared, lpMenuWidths) }
  1003.  
  1004. {   Similar to the IOleInPlaceFrame.InsertMenus. The explorer will put }
  1005. {  "File" and "Edit" pulldown in the File menu group, "View" and "Tools" }
  1006. {  in the Container menu group and "Help" in the Window menu group. Each }
  1007. {  pulldown menu will have a uniqu ID, FCIDM_MENU_FILE/EDIT/VIEW/TOOLS/HELP. }
  1008. {  The view is allowed to insert menuitems into those sub-menus by those }
  1009. {  IDs must be between FCIDM_SHVIEWFIRST and FCIDM_SHVIEWLAST. }
  1010.  
  1011.  
  1012. { IShellBrowser.SetMenuSB(hmenuShared, holemenu, hwndActiveObject) }
  1013.  
  1014. {   Similar to the IOleInPlaceFrame.SetMenu. The explorer ignores the }
  1015. {  holemenu parameter (reserved for future enhancement)  and performs }
  1016. {  menu-dispatch based on the menuitem IDs (see the description above). }
  1017. {  It is important to note that the explorer will add different }
  1018. {  set of menuitems depending on whether the view has a focus or not. }
  1019. {  Therefore, it is very important to call ISB.OnViewWindowActivate }
  1020. {  whenever the view window (or its children) gets the focus. }
  1021.  
  1022.  
  1023. { IShellBrowser.RemoveMenusSB(hmenuShared) }
  1024.  
  1025. {   Same as the IOleInPlaceFrame.RemoveMenus. }
  1026.  
  1027.  
  1028. { IShellBrowser.SetStatusTextSB(lpszStatusText) }
  1029.  
  1030. {   Same as the IOleInPlaceFrame.SetStatusText. It is also possible to }
  1031. {  send messages directly to the status window via SendControlMsg. }
  1032.  
  1033.  
  1034. { IShellBrowser.EnableModelessSB(fEnable) }
  1035.  
  1036. {   Same as the IOleInPlaceFrame.EnableModeless. }
  1037.  
  1038. { IShellBrowser.TranslateAcceleratorSB(lpmsg, wID) }
  1039.  
  1040. {   Same as the IOleInPlaceFrame.TranslateAccelerator, but will be }
  1041. {  never called because we don't support EXEs (i.e., the explorer has }
  1042. {  the message loop). This member function is defined here for possible }
  1043. {  future enhancement. }
  1044.  
  1045.  
  1046. { IShellBrowser.BrowseObject(pidl, wFlags) }
  1047.  
  1048. {   The view calls this member to let shell explorer browse to another }
  1049. {  folder. The pidl and wFlags specifies the folder to be browsed. }
  1050.  
  1051. {  Following three flags specifies whether it creates another window or not. }
  1052. {   SBSP_SAMEBROWSER  -- Browse to another folder with the same window. }
  1053. {   SBSP_NEWBROWSER   -- Creates another window for the specified folder. }
  1054. {   SBSP_DEFBROWSER   -- Default behavior (respects the view option). }
  1055.  
  1056. {  Following three flags specifies open, explore, or default mode. These   . }
  1057. {  are ignored if SBSP_SAMEBROWSER or (SBSP_DEFBROWSER && (single window   . }
  1058. {  browser || explorer)).                                                  . }
  1059. {   SBSP_OPENMODE     -- Use a normal folder window }
  1060. {   SBSP_EXPLOREMODE  -- Use an explorer window }
  1061. {   SBSP_DEFMODE      -- Use the same as the current window }
  1062.  
  1063. {  Following three flags specifies the pidl. }
  1064. {   SBSP_ABSOLUTE -- pidl is an absolute pidl (relative from desktop) }
  1065. {   SBSP_RELATIVE -- pidl is relative from the current folder. }
  1066. {   SBSP_PARENT   -- Browse the parent folder (ignores the pidl) }
  1067.  
  1068.  
  1069. { IShellBrowser.GetViewStateStream(grfMode, ppstm) }
  1070.  
  1071. {   The browser returns an IStream interface as the storage for view }
  1072. {  specific state information. }
  1073.  
  1074. {   grfMode -- Specifies the read/write access (STGM_READ/WRITE/READWRITE) }
  1075. {   ppstm   -- Specifies the LPSTREAM variable to be filled. }
  1076.  
  1077.  
  1078. { IShellBrowser.GetControlWindow(id, phwnd) }
  1079.  
  1080. {   The shell view may call this member function to get the window handle }
  1081. {  of Explorer controls (toolbar or status winodw -- FCW_TOOLBAR or }
  1082. {  FCW_STATUS). }
  1083.  
  1084.  
  1085. { IShellBrowser.SendControlMsg(id, uMsg, wParam, lParam, pret) }
  1086.  
  1087. {   The shell view calls this member function to send control messages to }
  1088. {  one of Explorer controls (toolbar or status window -- FCW_TOOLBAR or }
  1089. {  FCW_STATUS). }
  1090.  
  1091.  
  1092. { IShellBrowser.QueryActiveShellView(IShellView * ppshv) }
  1093.  
  1094. {   This member returns currently activated (displayed) shellview object. }
  1095. {  A shellview never need to call this member function. }
  1096.  
  1097.  
  1098. { IShellBrowser.OnViewWindowActive(pshv) }
  1099.  
  1100. {   The shell view window calls this member function when the view window }
  1101. {  (or one of its children) got the focus. It MUST call this member before }
  1102. {  calling IShellBrowser.InsertMenus, because it will insert different }
  1103. {  set of menu items depending on whether the view has the focus or not. }
  1104.  
  1105.  
  1106. { IShellBrowser.SetToolbarItems(lpButtons, nButtons, uFlags) }
  1107.  
  1108. {   The view calls this function to add toolbar items to the exporer's }
  1109. {  toolbar. "lpButtons" and "nButtons" specifies the array of toolbar }
  1110. {  items. "uFlags" must be one of FCT_MERGE, FCT_CONFIGABLE, FCT_ADDTOEND. }
  1111.  
  1112. { ------------------------------------------------------------------------- }
  1113.  
  1114.  
  1115. { Values for wFlags parameter of ISB.BrowseObject() member. }
  1116. const
  1117.   SBSP_DEFBROWSER      = $0000; 
  1118.   SBSP_SAMEBROWSER     = $0001; 
  1119.   SBSP_NEWBROWSER      = $0002; 
  1120.  
  1121.   SBSP_DEFMODE         = $0000; 
  1122.   SBSP_OPENMODE        = $0010; 
  1123.   SBSP_EXPLOREMODE     = $0020; 
  1124.  
  1125.   SBSP_ABSOLUTE        = $0000; 
  1126.   SBSP_RELATIVE        = $1000; 
  1127.   SBSP_PARENT          = $2000; 
  1128.  
  1129.   SBSP_INITIATEDBYHLINKFRAME            = $80000000; 
  1130.   SBSP_REDIRECT                         = $40000000; 
  1131.  
  1132.  
  1133. { Values for id parameter of ISB.GetWindow/SendControlMsg members. }
  1134.  
  1135. { WARNING: }
  1136. {  Any shell extensions which sends messages to those control windows }
  1137. { might not work in the future version of windows. If you really need }
  1138. { to send messages to them, (1) don't assume that those control window }
  1139. { always exist (i.e. GetControlWindow may fail) and (2) verify the window }
  1140. { class of the window before sending any messages. }
  1141.  
  1142.   FCW_STATUS          = $0001; 
  1143.   FCW_TOOLBAR         = $0002; 
  1144.   FCW_TREE            = $0003; 
  1145.  
  1146.  
  1147. { Values for uFlags paremeter of ISB.SetToolbarItems member. }
  1148.  
  1149.   FCT_MERGE           = $0001; 
  1150.   FCT_CONFIGABLE      = $0002; 
  1151.   FCT_ADDTOEND        = $0004; 
  1152.   
  1153. { ICommDlgBrowser.OnStateChange values }
  1154.  
  1155.   CDBOSC_SETFOCUS         = $00000000; 
  1156.   CDBOSC_KILLFOCUS        = $00000001; 
  1157.   CDBOSC_SELCHANGE        = $00000002; 
  1158.   CDBOSC_RENAME           = $00000003; 
  1159.  
  1160. { shellview select item flags }
  1161.  
  1162.   SVSI_DESELECT           = $0000; 
  1163.   SVSI_SELECT             = $0001; 
  1164.   SVSI_EDIT               = $0003;  { includes select }
  1165.   SVSI_DESELECTOTHERS     = $0004; 
  1166.   SVSI_ENSUREVISIBLE      = $0008; 
  1167.   SVSI_FOCUSED            = $0010; 
  1168.  
  1169. { shellview get item object flags }
  1170.  
  1171.   SVGIO_BACKGROUND        = $00000000; 
  1172.   SVGIO_SELECTION         = $00000001; 
  1173.   SVGIO_ALLVIEW           = $00000002; 
  1174.  
  1175. type
  1176.   HOLEMENU = HGLOBAL; // !!! should this be in ole2.pas?
  1177.   
  1178.   IShellView = interface;
  1179.   
  1180.   IShellBrowser = interface(IOleWindow)
  1181.     [SID_IShellBrowser]
  1182.     function InsertMenusSB(hMenuShared: HMENU; 
  1183.       out MenuWidths: TOleMenuGroupWidths): HResult; stdcall;
  1184.     function SetMenuSB(hMenuShared: HMENU;
  1185.       hOleMenuReserved: HOLEMENU; hwndActiveObject: HWND): HResult; stdcall;
  1186.     function RemoveMenusSB(hMenuShared: HMENU): HResult; stdcall;
  1187.     function SetStatusTextSB(StatusText: POleStr): HResult; stdcall;
  1188.     function EnableModelessSB(Enable: BOOL): HResult; stdcall;
  1189.     function TranslateAcceleratorSB(Msg: PMsg; ID: Word): HResult; stdcall;
  1190.     function BrowseObject(pidl: PItemIDList; flags: UINT): HResult; stdcall;
  1191.     function GetViewStateStream(Mode: DWORD; out Stream: IStream): HResult; stdcall;
  1192.     function GetControlWindow(ID: UINT; out Wnd: HWND): HResult; stdcall;
  1193.     function SendControlMsg(ID, Msg: UINT; wParm: WPARAM; lParm: LPARAM; 
  1194.       Result: LResult): HResult; stdcall;
  1195.     function QueryActiveShellView(var ShellView: IShellView): HResult; stdcall;
  1196.     function OnViewWindowActive(var ShellView: IShellView): HResult; stdcall;
  1197.     function SetToolbarItems(TBButton: PTBButton; 
  1198.       nButtons, uFlags: UINT): HResult; stdcall;
  1199.   end;
  1200.  
  1201.   TSBSCEnums = (SBSC_HIDE, SBSC_SHOW, SBSC_TOGGLE, SBSC_QUERY);
  1202.  
  1203. { CommandTarget ids. }
  1204.   TSBCMDIDEnums = ( 
  1205.     SBCMDID_ENABLESHOWTREE,
  1206.     SBCMDID_SHOWCONTROL,                { variant vt_i4 = loword = FCW_* hiword = SBSC_* }
  1207.     SBCMDID_CANCELNAVIGATION,           { cancel last navigation }
  1208.     SBCMDID_MAYSAVECHANGES,             { about to close and may save changes }
  1209.     SBCMDID_SETHLINKFRAME,              { variant vt_i4 = phlinkframe }
  1210.     SBCMDID_ENABLESTOP,                 { variant vt_bool = fEnable }
  1211.     SBCMDID_OPTIONS                     { the view.options page }
  1212.   );
  1213.  
  1214.  
  1215. { ICommDlgBrowser interface }
  1216.  
  1217. {  ICommDlgBrowser interface is the interface that is provided by the new }
  1218. { common dialog window to hook and modify the behavior of IShellView.  When }
  1219. { a default view is created, it queries its parent IShellBrowser for the }
  1220. { ICommDlgBrowser interface.  If supported, it calls out to that interface }
  1221. { in several cases that need to behave differently in a dialog. }
  1222.  
  1223. { Member functions: }
  1224.  
  1225. {  ICommDlgBrowser.OnDefaultCommand() }
  1226. {    Called when the user double-clicks in the view or presses Enter.  The }
  1227. {   browser should return S_OK if it processed the action itself, S_FALSE }
  1228. {   to let the view perform the default action. }
  1229.  
  1230. {  ICommDlgBrowser.OnStateChange(ULONG uChange) }
  1231. {    Called when some states in the view change.  'uChange' is one of the }
  1232. {   CDBOSC_* values.  This call is made after the state (selection, focus, }
  1233. {   etc) has changed.  There is no return value. }
  1234.  
  1235. {  ICommDlgBrowser.IncludeObject(LPCITEMIDLIST pidl) }
  1236. {    Called when the view is enumerating objects.  'pidl' is a relative }
  1237. {   IDLIST.  The browser should return S_OK to include the object in the }
  1238. {   view, S_FALSE to hide it }
  1239.  
  1240. { ------------------------------------------------------------------------- }
  1241.  
  1242.   ICommDlgBrowser = interface(IUnknown)
  1243.     [SID_ICommDlgBrowser]
  1244.     function OnDefaultCommand(var ShellView: IShellView): HResult; stdcall;
  1245.     function OnStateChange(var ShellView: IShellView; Change: ULONG): HResult; stdcall;
  1246.     function IncludeObject(var ShellView: IShellView; pidl: PItemIDList): HResult; stdcall;
  1247.   end;
  1248.  
  1249.  
  1250. { Interface:   IShellView }
  1251.  
  1252. { IShellView.ContextSensitiveHelp(fEnterMode) }
  1253.  
  1254. {   Inherited from IOleWindow.ContextSensitiveHelp. }
  1255.  
  1256.  
  1257. { IShellView.TranslateAccelerator(lpmsg) }
  1258.  
  1259. {   Similar to IOleInPlaceActiveObject.TranlateAccelerator. The explorer }
  1260. {  calls this function BEFORE any other translation. Returning S_OK }
  1261. {  indicates that the message was translated (eaten) and should not be }
  1262. {  translated or dispatched by the explorer. }
  1263.  
  1264.  
  1265. { IShellView.EnableModeless(fEnable) }
  1266.  
  1267. {   Similar to IOleInPlaceActiveObject.EnableModeless. }
  1268.  
  1269.  
  1270. { IShellView.UIActivate(uState) }
  1271.  
  1272. {   The explorer calls this member function whenever the activation }
  1273. {  state of the view window is changed by a certain event that is }
  1274. {  NOT caused by the shell view itself. }
  1275.  
  1276. {   SVUIA_DEACTIVATE will be passed when the explorer is about to }
  1277. {  destroy the shell view window; the shell view is supposed to remove }
  1278. {  all the extended UIs (typically merged menu and modeless popup windows). }
  1279.  
  1280. {   SVUIA_ACTIVATE_NOFOCUS will be passsed when the shell view is losing }
  1281. {  the input focus or the shell view has been just created without the }
  1282. {  input focus; the shell view is supposed to set menuitems appropriate }
  1283. {  for non-focused state (no selection specific items should be added). }
  1284.  
  1285. {   SVUIA_ACTIVATE_FOCUS will be passed when the explorer has just }
  1286. {  created the view window with the input focus; the shell view is }
  1287. {  supposed to set menuitems appropriate for focused state. }
  1288.  
  1289. {   SVUIA_INPLACEACTIVATE(new) will be passed when the shell view is opened }
  1290. {  within an ActiveX control, which is not a UI active. In this case, }
  1291. {  the shell view should not merge menus or put toolbas. To be compatible }
  1292. {  with Win95 client, we don't pass this value unless the view supports }
  1293. {  IShellView2. }
  1294.  
  1295. {   The shell view should not change focus within this member function. }
  1296. {  The shell view should not hook the WM_KILLFOCUS message to remerge }
  1297. {  menuitems. However, the shell view typically hook the WM_SETFOCUS }
  1298. {  message, and re-merge the menu after calling IShellBrowser. }
  1299. {  OnViewWindowActivated. }
  1300.  
  1301.  
  1302. { IShellView.Refresh() }
  1303.  
  1304. {   The explorer calls this member when the view needs to refresh its }
  1305. {  contents (such as when the user hits F5 key). }
  1306.  
  1307.  
  1308. { IShellView.CreateViewWindow }
  1309.  
  1310. {   This member creates the view window (right-pane of the explorer or the }
  1311. {  client window of the folder window). }
  1312.  
  1313.  
  1314. { IShellView.DestroyViewWindow }
  1315.  
  1316. {   This member destroys the view window. }
  1317.  
  1318.  
  1319. { IShellView.GetCurrentInfo }
  1320.  
  1321. {   This member returns the folder settings. }
  1322.  
  1323.  
  1324. { IShellView.AddPropertySHeetPages }
  1325.  
  1326. {   The explorer calls this member when it is opening the option property }
  1327. {  sheet. This allows the view to add additional pages to it. }
  1328.  
  1329.  
  1330. { IShellView.SaveViewState() }
  1331.  
  1332. {   The explorer calls this member when the shell view is supposed to }
  1333. {  store its view settings. The shell view is supposed to get a view }
  1334. {  stream by calling IShellBrowser.GetViewStateStream and store the }
  1335. {  current view state into that stream. }
  1336.  
  1337.  
  1338. { IShellView.SelectItem(pidlItem, uFlags) }
  1339.  
  1340. {   The explorer calls this member to change the selection state of }
  1341. {  item(s) within the shell view window.  If pidlItem is NULL and uFlags }
  1342. {  is SVSI_DESELECTOTHERS, all items should be deselected. }
  1343.  
  1344. { ------------------------------------------------------------------------- }
  1345.  
  1346. { uState values for IShellView.UIActivate }
  1347.  
  1348.   TSVUIAEnums = ( 
  1349.     SVUIA_DEACTIVATE,
  1350.     SVUIA_ACTIVATE_NOFOCUS,
  1351.     SVUIA_ACTIVATE_FOCUS,
  1352.     SVUIA_INPLACEACTIVATE               { new flag for IShellView2 }
  1353.   );
  1354.  
  1355.   IShellView = interface(IOleWindow)
  1356.     [SID_IShellView]
  1357.     function TranslateAccelerator(var Msg: TMsg): HResult; stdcall;
  1358.     function EnableModeless(Enable: Boolean): HResult; stdcall;
  1359.     function UIActivate(State: UINT): HResult; stdcall;
  1360.     function Refresh: HResult; stdcall;
  1361.     function CreateViewWindow(PrevView: IShellView;
  1362.       var FolderSettings: TFolderSettings; ShellBrowser: IShellBrowser;
  1363.       var Rect: TRect; out Wnd: HWND): HResult; stdcall;
  1364.     function DestroyViewWindow: HResult; stdcall;
  1365.     function GetCurrentInfo(out FolderSettings: TFolderSettings): HResult; stdcall;
  1366.     function AddPropertySheetPages(Reseved: DWORD;
  1367.       lpfnAddPage: TFNAddPropSheetPage; lParam: LPARAM): HResult; stdcall;
  1368.     function SaveViewState: HResult; stdcall;
  1369.     function SelectItem(pidl: PItemIDList; flags: UINT): HResult; stdcall;
  1370.     function GetItemObject(Item: UINT; iid: TIID; IPtr: Pointer): HResult; stdcall;
  1371.   end;
  1372.  
  1373. const
  1374.   SV2GV_CURRENTVIEW     = -1; 
  1375.   SV2GV_DEFAULTVIEW     = -2; 
  1376.  
  1377. type
  1378.   TShellViewID = TGUID;
  1379.   PShellViewID = ^TShellViewID;
  1380.   
  1381.   PSV2CreateParams = ^TSV2CreateParams;
  1382.   TSV2CreateParams = packed record 
  1383.     cbSize: DWORD;
  1384.     psvPrev: IShellView;
  1385.     pfs: PFolderSettings;
  1386.     psbOwner: IShellBrowser;
  1387.     prcView: PRect;
  1388.     pvid: PShellViewID;
  1389.     hwndView: HWND;
  1390.   end;
  1391.  
  1392.   IShellView2 = interface(IShellView)
  1393.     [SID_IShellView2]
  1394.     function GetView(pvid: PShellViewID; uView: ULONG): HResult; stdcall;
  1395.     function CreateViewWindow2(SV2CreateParams: PSV2CreateParams): HResult; stdcall;
  1396.   end;
  1397.   
  1398. { ------------------------------------------------------------------------- }
  1399.  
  1400. const
  1401.   STRRET_WSTR         = $0000;          { Use STRRET.pOleStr }
  1402.   STRRET_OFFSET       = $0001;          { Use STRRET.uOffset to Ansi }
  1403.   STRRET_CSTR         = $0002;          { Use STRRET.cStr }
  1404.  
  1405. type
  1406. { record for returning strings from IShellFolder member functions }
  1407.  
  1408.   PSTRRet = ^TStrRet;
  1409.   TStrRet = packed record
  1410.      uType: UINT;              { One of the STRRET_* values }
  1411.      case Integer of
  1412.        0: (pOleStr: LPWSTR);                    { OLESTR that will be freed }
  1413.        1: (pStr: LPSTR);                        { ANSI string that will be freed (needed?) }
  1414.        2: (uOffset: UINT);                      { Offset into SHITEMID (ANSI) }
  1415.        3: (cStr: array[0..MAX_PATH-1] of Char); { Buffer to fill in }
  1416.     end;
  1417.  
  1418. { SHGetPathFromIDList }
  1419.  
  1420. { This function assumes the size of the buffer (MAX_PATH). The pidl
  1421.   should point to a file system object. }
  1422.  
  1423. function SHGetPathFromIDListA(pidl: PItemIDList; pszPath: PAnsiChar): BOOL; stdcall;
  1424. function SHGetPathFromIDListW(pidl: PItemIDList; pszPath: PWideChar): BOOL; stdcall;
  1425. function SHGetPathFromIDList(pidl: PItemIDList; pszPath: PChar): BOOL; stdcall;
  1426.  
  1427. { SHGetSpecialFolderLocation }
  1428.  
  1429. { Caller should call SHFree to free the returned pidl. }
  1430.  
  1431. const
  1432. { registry entries for special paths are kept in : }
  1433.  
  1434.   REGSTR_PATH_SPECIAL_FOLDERS   = REGSTR_PATH_EXPLORER + '\Shell Folders';
  1435.   CSIDL_DESKTOP                       = $0000; 
  1436.   CSIDL_PROGRAMS                      = $0002; 
  1437.   CSIDL_CONTROLS                      = $0003; 
  1438.   CSIDL_PRINTERS                      = $0004; 
  1439.   CSIDL_PERSONAL                      = $0005; 
  1440.   CSIDL_FAVORITES                     = $0006; 
  1441.   CSIDL_STARTUP                       = $0007; 
  1442.   CSIDL_RECENT                        = $0008; 
  1443.   CSIDL_SENDTO                        = $0009; 
  1444.   CSIDL_BITBUCKET                     = $000a; 
  1445.   CSIDL_STARTMENU                     = $000b; 
  1446.   CSIDL_DESKTOPDIRECTORY              = $0010; 
  1447.   CSIDL_DRIVES                        = $0011; 
  1448.   CSIDL_NETWORK                       = $0012; 
  1449.   CSIDL_NETHOOD                       = $0013; 
  1450.   CSIDL_FONTS                         = $0014; 
  1451.   CSIDL_TEMPLATES                     = $0015; 
  1452.   CSIDL_COMMON_STARTMENU              = $0016; 
  1453.   CSIDL_COMMON_PROGRAMS               = $0017; 
  1454.   CSIDL_COMMON_STARTUP                = $0018; 
  1455.   CSIDL_COMMON_DESKTOPDIRECTORY       = $0019; 
  1456.   CSIDL_APPDATA                       = $001a; 
  1457.   CSIDL_PRINTHOOD                     = $001b; 
  1458.  
  1459. function SHGetSpecialFolderLocation(hwndOwner: HWND; nFolder: Integer;
  1460.   var ppidl: PItemIDList): HResult; stdcall;
  1461.  
  1462.   
  1463. { SHBrowseForFolder API }
  1464.  
  1465. type
  1466.   TFNBFFCallBack = function(Wnd: HWND; uMsg: UINT; lParam, lpData: LPARAM): Integer stdcall;
  1467.   
  1468.   PBrowseInfoA = ^TBrowseInfoA;
  1469.   PBrowseInfoW = ^TBrowseInfoW;
  1470.   PBrowseInfo = PBrowseInfoA;
  1471.   TBrowseInfoA = packed record
  1472.     hwndOwner: HWND;
  1473.     pidlRoot: PItemIDList;
  1474.     pszDisplayName: PAnsiChar;  { Return display name of item selected. }
  1475.     lpszTitle: PAnsiChar;      { text to go in the banner over the tree. }
  1476.     ulFlags: UINT;           { Flags that control the return stuff }
  1477.     lpfn: TFNBFFCallBack;
  1478.     lParam: LPARAM;          { extra info that's passed back in callbacks }
  1479.     iImage: Integer;         { output var: where to return the Image index. }
  1480.   end;
  1481.   TBrowseInfoW = packed record
  1482.     hwndOwner: HWND;
  1483.     pidlRoot: PItemIDList;
  1484.     pszDisplayName: PWideChar;  { Return display name of item selected. }
  1485.     lpszTitle: PWideChar;      { text to go in the banner over the tree. }
  1486.     ulFlags: UINT;           { Flags that control the return stuff }
  1487.     lpfn: TFNBFFCallBack;
  1488.     lParam: LPARAM;          { extra info that's passed back in callbacks }
  1489.     iImage: Integer;         { output var: where to return the Image index. }
  1490.   end;
  1491.   TBrowseInfo = TBrowseInfoA;
  1492.  
  1493. const
  1494. { Browsing for directory. }
  1495.  
  1496.   BIF_RETURNONLYFSDIRS   = $0001;  { For finding a folder to start document searching }
  1497.   BIF_DONTGOBELOWDOMAIN  = $0002;  { For starting the Find Computer }
  1498.   BIF_STATUSTEXT         = $0004;
  1499.   BIF_RETURNFSANCESTORS  = $0008;
  1500.  
  1501.   BIF_BROWSEFORCOMPUTER  = $1000;  { Browsing for Computers. }
  1502.   BIF_BROWSEFORPRINTER   = $2000;  { Browsing for Printers }
  1503.   BIF_BROWSEINCLUDEFILES = $4000;  { Browsing for Everything }
  1504.  
  1505. { message from browser }
  1506.  
  1507.   BFFM_INITIALIZED       = 1;
  1508.   BFFM_SELCHANGED        = 2;
  1509.  
  1510. { messages to browser }
  1511.  
  1512.   BFFM_SETSTATUSTEXTA         = WM_USER + 100; 
  1513.   BFFM_ENABLEOK               = WM_USER + 101; 
  1514.   BFFM_SETSELECTIONA          = WM_USER + 102; 
  1515.   BFFM_SETSELECTIONW          = WM_USER + 103; 
  1516.   BFFM_SETSTATUSTEXTW         = WM_USER + 104; 
  1517.  
  1518.   BFFM_SETSTATUSTEXT      = BFFM_SETSTATUSTEXTA; 
  1519.   BFFM_SETSELECTION       = BFFM_SETSELECTIONA; 
  1520.  
  1521. function SHBrowseForFolderA(var lpbi: TBrowseInfoA): PItemIDList; stdcall;
  1522. function SHBrowseForFolderW(var lpbi: TBrowseInfoW): PItemIDList; stdcall;
  1523. function SHBrowseForFolder(var lpbi: TBrowseInfo): PItemIDList; stdcall;
  1524.  
  1525. { SHLoadInProc }
  1526.  
  1527. { When this function is called, the shell calls CoCreateInstance
  1528.   (or equivalent) with CLSCTX_INPROC_SERVER and the specified CLSID
  1529.   from within the shell's process and release it immediately. }
  1530.  
  1531. function SHLoadInProc(rclsid: TCLSID): HRESULT; stdcall;
  1532.  
  1533. { IEnumIDList interface }
  1534.  
  1535. { IShellFolder.EnumObjects member returns an IEnumIDList object. }
  1536.  
  1537. type
  1538.   IEnumIDList = interface(IUnknown)
  1539.     [SID_IEnumIDList]
  1540.     function Next(celt: ULONG; out rgelt: PItemIDList;
  1541.       var pceltFetched: ULONG): HResult; stdcall;
  1542.     function Skip(celt: ULONG): HResult; stdcall;
  1543.     function Reset: HResult; stdcall;
  1544.     function Clone(out ppenum: IEnumIDList): HResult; stdcall;
  1545.   end;
  1546.  
  1547. { IShellFolder interface }
  1548.  
  1549. { [Member functions] }
  1550.  
  1551. { IShellFolder.BindToObject(pidl, pbc, riid, ppvOut)
  1552.   This function returns an instance of a sub-folder which is specified
  1553.   by the IDList (pidl).
  1554.  IShellFolder.BindToStorage(pidl, pbc, riid, ppvObj)
  1555.    This function returns a storage instance of a sub-folder which is
  1556.    specified by the IDList (pidl). The shell never calls this member
  1557.    function in the first release of Win95.
  1558.  IShellFolder.CompareIDs(lParam, pidl1, pidl2)
  1559.    This function compares two IDLists and returns the result. The shell
  1560.    explorer always passes 0 as lParam, which indicates 'sort by name'.
  1561.    It should return 0 (as CODE of the scode), if two id indicates the
  1562.    same object; negative value if pidl1 should be placed before pidl2;
  1563.    positive value if pidl2 should be placed before pidl1.
  1564.  IShellFolder.CreateViewObject(hwndOwner, riid, ppvOut)
  1565.    This function creates a view object of the folder itself. The view
  1566.    object is a difference instance from the shell folder object.
  1567.    "hwndOwner" can be used  as the owner window of its dialog box or
  1568.       menu during the lifetime of the view object.
  1569.    instance which has only one reference count. The explorer may create
  1570.    more than one instances of view object from one shell folder object
  1571.    and treat them as separate instances.
  1572.  IShellFolder.GetAttributesOf(cidl, apidl, prgfInOut)
  1573.    This function returns the attributes of specified objects in that
  1574.    folder. 'cidl' and 'apidl' specifies objects. 'apidl' contains only
  1575.    simple IDLists. The explorer initializes *prgfInOut with a set of
  1576.    flags to be evaluated. The shell folder may optimize the operation
  1577.    by not returning unspecified flags.
  1578.  IShellFolder.GetUIObjectOf(hwndOwner, cidl, apidl, riid, prgfInOut, ppvOut)
  1579.    This function creates a UI object to be used for specified objects.
  1580.    The shell explorer passes either IID_IDataObject (for transfer operation)
  1581.    or IID_IContextMenu (for context menu operation) as riid.
  1582.  IShellFolder.GetDisplayNameOf
  1583.    This function returns the display name of the specified object.
  1584.    If the ID contains the display name (in the locale character set),
  1585.    it returns the offset to the name. Otherwise, it returns a pointer
  1586.    to the display name string (UNICODE), which is allocated by the
  1587.    task allocator, or fills in a buffer.
  1588.  IShellFolder.SetNameOf
  1589.    This function sets the display name of the specified object.
  1590.    If it changes the ID as well, it returns the new ID which is
  1591.    alocated by the task allocator. }
  1592.  
  1593. const
  1594. { IShellFolder.GetDisplayNameOf/SetNameOf uFlags }
  1595.  
  1596.   SHGDN_NORMAL           = 0;         { default (display purpose) }
  1597.   SHGDN_INFOLDER         = 1;         { displayed under a folder (relative) }
  1598.   SHGDN_FORADDRESSBAR    = $4000;     { for displaying in the address (drives dropdown) bar }
  1599.   SHGDN_FORPARSING       = $8000;     { for ParseDisplayName or path }
  1600.  
  1601. { IShellFolder.EnumObjects }
  1602.  
  1603.   SHCONTF_FOLDERS         = 32;       { for shell browser }
  1604.   SHCONTF_NONFOLDERS      = 64;       { for default view }
  1605.   SHCONTF_INCLUDEHIDDEN   = 128;      { for hidden/system objects }
  1606.  
  1607. { IShellFolder.GetAttributesOf flags }
  1608.  
  1609.   SFGAO_CANCOPY           = DROPEFFECT_COPY; { Objects can be copied }
  1610.   SFGAO_CANMOVE           = DROPEFFECT_MOVE; { Objects can be moved }
  1611.   SFGAO_CANLINK           = DROPEFFECT_LINK; { Objects can be linked }
  1612.   SFGAO_CANRENAME         = $00000010;       { Objects can be renamed }
  1613.   SFGAO_CANDELETE         = $00000020;       { Objects can be deleted }
  1614.   SFGAO_HASPROPSHEET      = $00000040;       { Objects have property sheets }
  1615.   SFGAO_DROPTARGET        = $00000100;       { Objects are drop target }
  1616.   SFGAO_CAPABILITYMASK    = $00000177;      
  1617.   SFGAO_LINK              = $00010000;       { Shortcut (link) }
  1618.   SFGAO_SHARE             = $00020000;       { shared }
  1619.   SFGAO_READONLY          = $00040000;       { read-only }
  1620.   SFGAO_GHOSTED           = $00080000;       { ghosted icon }
  1621.   SFGAO_DISPLAYATTRMASK   = $000F0000;      
  1622.   SFGAO_FILESYSANCESTOR   = $10000000;       { It contains file system folder }
  1623.   SFGAO_FOLDER            = $20000000;       { It's a folder. }
  1624.   SFGAO_FILESYSTEM        = $40000000;       { is a file system thing (file/folder/root) }
  1625.   SFGAO_HASSUBFOLDER      = $80000000;       { Expandable in the map pane }
  1626.   SFGAO_CONTENTSMASK      = $80000000;      
  1627.   SFGAO_VALIDATE          = $01000000;       { invalidate cached information }
  1628.   SFGAO_REMOVABLE         = $02000000;       { is this removeable media? }
  1629.   SFGAO_COMPRESSED        = $04000000;       { Object is compressed (use alt color) }
  1630.  
  1631. type
  1632.   IShellFolder = interface(IUnknown)
  1633.     [SID_IShellFolder]
  1634.     function ParseDisplayName(hwndOwner: HWND;
  1635.       pbcReserved: Pointer; lpszDisplayName: POLESTR; out pchEaten: ULONG; 
  1636.       out ppidl: PItemIDList; var dwAttributes: ULONG): HResult; stdcall;
  1637.     function EnumObjects(hwndOwner: HWND; grfFlags: DWORD;
  1638.       out EnumIDList: IEnumIDList): HResult; stdcall;
  1639.     function BindToObject(pidl: PItemIDList; pbcReserved: Pointer;
  1640.       const riid: TIID; out ppvOut: Pointer): HResult; stdcall;
  1641.     function BindToStorage(pidl: PItemIDList; pbcReserved: Pointer;
  1642.       const riid: TIID; out ppvObj: Pointer): HResult; stdcall;
  1643.     function CompareIDs(lParam: LPARAM;
  1644.       pidl1, pidl2: PItemIDList): HResult; stdcall;
  1645.     function CreateViewObject(hwndOwner: HWND; const riid: TIID;
  1646.       out ppvOut: Pointer): HResult; stdcall;
  1647.     function GetAttributesOf(cidl: UINT; var apidl: PItemIDList;
  1648.       var rgfInOut: UINT): HResult; stdcall;
  1649.     function GetUIObjectOf(hwndOwner: HWND; cidl: UINT; var apidl: PItemIDList;
  1650.       const riid: TIID; prgfInOut: Pointer; out ppvOut: Pointer): HResult; stdcall;
  1651.     function GetDisplayNameOf(pidl: PItemIDList; uFlags: DWORD;
  1652.       var lpName: TStrRet): HResult; stdcall;
  1653.     function SetNameOf(hwndOwner: HWND; pidl: PItemIDList; lpszName: POLEStr; 
  1654.       uFlags: DWORD; var ppidlOut: PItemIDList): HResult; stdcall;
  1655.   end;
  1656.  
  1657. { Helper function which returns a IShellFolder interface to the desktop
  1658.   folder. This is equivalent to call CoCreateInstance with CLSID_ShellDesktop. }
  1659.  
  1660. function SHGetDesktopFolder(var ppshf: IShellFolder): HResult; stdcall;
  1661.  
  1662. const
  1663. { Clipboard format which may be supported by IDataObject from system
  1664.   defined shell folders (such as directories, network, ...). }
  1665.   
  1666.   CFSTR_SHELLIDLIST           = 'Shell IDList Array';     { CF_IDLIST }
  1667.   CFSTR_SHELLIDLISTOFFSET     = 'Shell Object Offsets';   { CF_OBJECTPOSITIONS }
  1668.   CFSTR_NETRESOURCES          = 'Net Resource';           { CF_NETRESOURCE }
  1669.   CFSTR_FILEDESCRIPTORA       = 'FileGroupDescriptor';    { CF_FILEGROUPDESCRIPTORA }
  1670.   CFSTR_FILEDESCRIPTORW       = 'FileGroupDescriptorW';   { CF_FILEGROUPDESCRIPTORW }
  1671.   CFSTR_FILECONTENTS          = 'FileContents';           { CF_FILECONTENTS }
  1672.   CFSTR_FILENAMEA             = 'FileName';               { CF_FILENAMEA }
  1673.   CFSTR_FILENAMEW             = 'FileNameW';              { CF_FILENAMEW }
  1674.   CFSTR_PRINTERGROUP          = 'PrinterFriendlyName';    { CF_PRINTERS }
  1675.   CFSTR_FILENAMEMAPA          = 'FileNameMap';            { CF_FILENAMEMAPA }
  1676.   CFSTR_FILENAMEMAPW          = 'FileNameMapW';           { CF_FILENAMEMAPW }
  1677.   CFSTR_PREFERREDDROPEFFECT   = 'Preferred DropEffect'; 
  1678.  
  1679.   CFSTR_FILEDESCRIPTOR        = CFSTR_FILEDESCRIPTORA; 
  1680.   CFSTR_FILENAME              = CFSTR_FILENAMEA; 
  1681.   CFSTR_FILENAMEMAP           = CFSTR_FILENAMEMAPA; 
  1682.  
  1683.  
  1684. { CF_OBJECTPOSITIONS }
  1685.  
  1686.   DVASPECT_SHORTNAME     = 2; { use for CF_HDROP to get short name version }
  1687.  
  1688.  
  1689. type
  1690. { format of CF_NETRESOURCE }
  1691.  
  1692.   PNResArray = ^TNResArray;
  1693.   TNResArray = packed record { anr }
  1694.     cItems: UINT;
  1695.     nr: array[0..0] of TNetResource;
  1696.   end;
  1697.  
  1698. { format of CF_IDLIST }
  1699.  
  1700.   PIDA = ^TIDA;
  1701.   TIDA = packed record
  1702.     cidl: UINT;                      { number of relative IDList }
  1703.     aoffset: array[0..0] of UINT;    { [0]: folder IDList, [1]-[cidl]: item IDList }
  1704.   end;
  1705.  
  1706.  
  1707. const
  1708. { FILEDESCRIPTOR.dwFlags field indicate which fields are to be used }
  1709.  
  1710.     FD_CLSID            = $0001;
  1711.     FD_SIZEPOINT        = $0002;
  1712.     FD_ATTRIBUTES       = $0004;
  1713.     FD_CREATETIME       = $0008;
  1714.     FD_ACCESSTIME       = $0010;
  1715.     FD_WRITESTIME       = $0020;
  1716.     FD_FILESIZE         = $0040;
  1717.     FD_LINKUI           = $8000;       { 'link' UI is prefered }
  1718.  
  1719. type
  1720.   PFileDescriptorA = ^TFileDescriptorA;
  1721.   PFileDescriptorW = ^TFileDescriptorW;
  1722.   PFileDescriptor = PFileDescriptorA;
  1723.   TFileDescriptorA = packed record { fod }
  1724.     dwFlags: DWORD;
  1725.     clsid: TCLSID;
  1726.     sizel: TSize;
  1727.     pointl: TPoint;
  1728.     dwFileAttributes: DWORD;
  1729.     ftCreationTime: TFileTime;
  1730.     ftLastAccessTime: TFileTime;
  1731.     ftLastWriteTime: TFileTime;
  1732.     nFileSizeHigh: DWORD;
  1733.     nFileSizeLow: DWORD;
  1734.     cFileName: array[0..MAX_PATH-1] of AnsiChar;
  1735.   end;
  1736.   TFileDescriptorW = packed record { fod }
  1737.     dwFlags: DWORD;
  1738.     clsid: TCLSID;
  1739.     sizel: TSize;
  1740.     pointl: TPoint;
  1741.     dwFileAttributes: DWORD;
  1742.     ftCreationTime: TFileTime;
  1743.     ftLastAccessTime: TFileTime;
  1744.     ftLastWriteTime: TFileTime;
  1745.     nFileSizeHigh: DWORD;
  1746.     nFileSizeLow: DWORD;
  1747.     cFileName: array[0..MAX_PATH-1] of WideChar;
  1748.   end;
  1749.   TFileDescriptor = TFileDescriptorA;
  1750.  
  1751. { format of CF_FILEGROUPDESCRIPTOR }
  1752.  
  1753.   PFileGroupDescriptor = ^TFileGroupDescriptor;
  1754.   TFileGroupDescriptor = packed record { fgd }
  1755.     cItems: UINT;
  1756.     fgd: array[0..0] of TFileDescriptor;
  1757.   end;
  1758.  
  1759. { format of CF_HDROP and CF_PRINTERS, in the HDROP case the data that follows
  1760.   is a double null terinated list of file names, for printers they are printer
  1761.   friendly names }
  1762.  
  1763.   PDropFiles = ^TDropFiles;
  1764.   TDropFiles = packed record
  1765.     pFiles: DWORD;                       { offset of file list }
  1766.     pt: TPoint;                          { drop point (client coords) }
  1767.     fNC: BOOL;                           { is it on NonClient area }
  1768.                      { and pt is in screen coords }
  1769.     fWide: BOOL;                         { WIDE character switch }
  1770.   end;
  1771.  
  1772. { File System Notification APIs }
  1773.  
  1774. const
  1775. { File System Notification flags }
  1776.  
  1777.   SHCNE_RENAMEITEM          = $00000001;
  1778.   SHCNE_CREATE              = $00000002;
  1779.   SHCNE_DELETE              = $00000004;
  1780.   SHCNE_MKDIR               = $00000008;
  1781.   SHCNE_RMDIR               = $00000010;
  1782.   SHCNE_MEDIAINSERTED       = $00000020;
  1783.   SHCNE_MEDIAREMOVED        = $00000040;
  1784.   SHCNE_DRIVEREMOVED        = $00000080;
  1785.   SHCNE_DRIVEADD            = $00000100;
  1786.   SHCNE_NETSHARE            = $00000200;
  1787.   SHCNE_NETUNSHARE          = $00000400;
  1788.   SHCNE_ATTRIBUTES          = $00000800;
  1789.   SHCNE_UPDATEDIR           = $00001000;
  1790.   SHCNE_UPDATEITEM          = $00002000;
  1791.   SHCNE_SERVERDISCONNECT    = $00004000;
  1792.   SHCNE_UPDATEIMAGE         = $00008000;
  1793.   SHCNE_DRIVEADDGUI         = $00010000;
  1794.   SHCNE_RENAMEFOLDER        = $00020000;
  1795.   SHCNE_FREESPACE           = $00040000;
  1796.   SHCNE_EXTENDED_EVENT      = $00080000;
  1797.  
  1798.   SHCNE_ASSOCCHANGED        = $08000000;
  1799.  
  1800.   SHCNE_DISKEVENTS          = $0002381F;
  1801.   SHCNE_GLOBALEVENTS        = $0C0581E0; { Events that dont match pidls first }
  1802.   SHCNE_ALLEVENTS           = $7FFFFFFF;
  1803.   SHCNE_INTERRUPT           = $80000000; { The presence of this flag indicates }
  1804.                      { that the event was generated by an }
  1805.                      { interrupt.  It is stripped out before }
  1806.                      { the clients of SHCNNotify_ see it. }
  1807.  
  1808.   SHCNEE_THEMECHANGED       = $00000001;
  1809.                      
  1810. { uFlags & SHCNF_TYPE is an ID which indicates what dwItem1 and dwItem2 mean }
  1811.  
  1812.   SHCNF_IDLIST          = $0000;        { LPITEMIDLIST }
  1813.   SHCNF_PATHA           = $0001;        { path name }
  1814.   SHCNF_PRINTERA        = $0002;        { printer friendly name }
  1815.   SHCNF_DWORD           = $0003;        { DWORD }
  1816.   SHCNF_PATHW           = $0005;        { path name }
  1817.   SHCNF_PRINTERW        = $0006;        { printer friendly name }
  1818.   SHCNF_TYPE            = $00FF; 
  1819.   SHCNF_FLUSH           = $1000; 
  1820.   SHCNF_FLUSHNOWAIT     = $2000; 
  1821.  
  1822.   SHCNF_PATH          = SHCNF_PATHA; 
  1823.   SHCNF_PRINTER       = SHCNF_PRINTERA; 
  1824.  
  1825. { APIs }
  1826.  
  1827. procedure SHChangeNotify(wEventId: Longint; uFlags: UINT;
  1828.   dwItem1, dwItem2: Pointer); stdcall;
  1829. procedure SHAddToRecentDocs(uFlags: UINT; pv: Pointer); stdcall;
  1830. function SHGetInstanceExplorer(var ppUnk: IUnknown): HResult; stdcall;
  1831.  
  1832. { SHAddToRecentDocs }
  1833.  
  1834. const
  1835.   SHARD_PIDL          = $00000001; 
  1836.   SHARD_PATHA         = $00000002; 
  1837.   SHARD_PATHW         = $00000003; 
  1838.  
  1839.   SHARD_PATH      = SHARD_PATHA; 
  1840.  
  1841.  
  1842. { SHGetDataFromIDList}
  1843.  
  1844. const
  1845.   SHGDFIL_FINDDATA            = 1; 
  1846.   SHGDFIL_NETRESOURCE         = 2; 
  1847.   SHGDFIL_DESCRIPTIONID       = 3; 
  1848.  
  1849.   SHDID_ROOT_REGITEM              = 1; 
  1850.   SHDID_FS_FILE                   = 2; 
  1851.   SHDID_FS_DIRECTORY              = 3; 
  1852.   SHDID_FS_OTHER                  = 4; 
  1853.   SHDID_COMPUTER_DRIVE35          = 5; 
  1854.   SHDID_COMPUTER_DRIVE525         = 6; 
  1855.   SHDID_COMPUTER_REMOVABLE        = 7; 
  1856.   SHDID_COMPUTER_FIXED            = 8; 
  1857.   SHDID_COMPUTER_NETDRIVE         = 9; 
  1858.   SHDID_COMPUTER_CDROM            = 10; 
  1859.   SHDID_COMPUTER_RAMDISK          = 11; 
  1860.   SHDID_COMPUTER_OTHER            = 12; 
  1861.   SHDID_NET_DOMAIN                = 13; 
  1862.   SHDID_NET_SERVER                = 14; 
  1863.   SHDID_NET_SHARE                 = 15; 
  1864.   SHDID_NET_RESTOFNET             = 16; 
  1865.   SHDID_NET_OTHER                 = 17; 
  1866.  
  1867. type
  1868.   PSHDescriptionID = ^TSHDescriptionID;
  1869.   TSHDescriptionID = packed record 
  1870.     dwDescriptionId: DWORD;
  1871.     Id: TCLSID;
  1872.   end;
  1873.  
  1874. function SHGetDataFromIDListA(psf: IShellFolder; pidl: PItemIDList;
  1875.   nFormat: Integer; ptr: Pointer; cb: Integer): HResult; stdcall;
  1876. function SHGetDataFromIDListW(psf: IShellFolder; pidl: PItemIDList;
  1877.   nFormat: Integer; ptr: Pointer; cb: Integer): HResult; stdcall;
  1878. function SHGetDataFromIDList(psf: IShellFolder; pidl: PItemIDList;
  1879.   nFormat: Integer; ptr: Pointer; cb: Integer): HResult; stdcall;
  1880.  
  1881. implementation
  1882.  
  1883. const 
  1884.   shell32 = 'shell32.dll';
  1885.  
  1886. procedure SHAddToRecentDocs;             external shell32 name 'SHAddToRecentDocs';
  1887. function SHBrowseForFolderA;          external shell32 name 'SHBrowseForFolderA';
  1888. function SHBrowseForFolderW;          external shell32 name 'SHBrowseForFolderW';
  1889. function SHBrowseForFolder;          external shell32 name 'SHBrowseForFolderA';
  1890. procedure SHChangeNotify;                external shell32 name 'SHChangeNotify';
  1891. function SHGetDataFromIDListA;        external shell32 name 'SHGetDataFromIDListA';
  1892. function SHGetDataFromIDListW;        external shell32 name 'SHGetDataFromIDListW';
  1893. function SHGetDataFromIDList;        external shell32 name 'SHGetDataFromIDListA';
  1894. function SHGetDesktopFolder;            external shell32 name 'SHGetDesktopFolder';
  1895. function SHGetInstanceExplorer;         external shell32 name 'SHGetInstanceExplorer';
  1896. function SHGetMalloc;                   external shell32 name 'SHGetMalloc';
  1897. function SHGetPathFromIDListA;        external shell32 name 'SHGetPathFromIDListA';
  1898. function SHGetPathFromIDListW;        external shell32 name 'SHGetPathFromIDListW';
  1899. function SHGetPathFromIDList;        external shell32 name 'SHGetPathFromIDListA';
  1900. function SHGetSpecialFolderLocation;    external shell32 name 'SHGetSpecialFolderLocation';
  1901. function SHLoadInProc;                  external shell32 name 'SHLoadInProc';
  1902.  
  1903. end.
  1904.  
  1905.  
  1906.